Guest User

Untitled

a guest
Feb 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. def prep_nnet_arch(n_depth, n_size, activation, colormode, alpha):
  2. layers = [5] #x, y, r, z1, z2
  3. for i in range(n_depth):
  4. layers.append(n_size)
  5.  
  6. colormode = colormode.lower()
  7.  
  8. ### Output layer. Append number of output neurons depending on which colormode is selected
  9. if colormode in ["rgb", "hsv", "hsl"] : #RGB
  10. if not alpha:
  11. layers.append(3)
  12. else:
  13. layers.append(4)
  14. elif colormode == "cmyk":
  15. if not alpha:
  16. layers.append(4)
  17. else:
  18. layers.append(5)
  19. elif colormode == "bw":
  20. if not alpha:
  21. layers.append(1)
  22. else:
  23. layers.append(2)
  24. else:
  25. print("Inserted colormode '{}' is not part ob supported ones: [rgb, bw, cmyk, hsv, hsl]".format(colormode))
  26. raise Exception("Non-supported colormode {}".format(colormode))
  27.  
  28. possibles = ["sigmoid", "tanh", "relu", "identity", "softsign", "sin", "cos", "softmax"]
  29. if not activation.lower() in possibles:
  30. print('defined activation {} not supported in {}'.format(activation, str(possibles)))
  31. return None
  32.  
  33. activations_fnc = [activation] * (len(layers)-2)
  34. activations_fnc.append("sigmoid")
  35.  
  36. return layers, activations_fnc
Add Comment
Please, Sign In to add comment