Created
March 11, 2019 20:52
-
-
Save jonnor/6f95661b717b1aad36d0c9fb06d77bfd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras | |
def mlp(n_features, n_classes, first, hidden, activation): | |
from keras.layers import Dense | |
shape = (n_features, 1) | |
model = keras.Sequential() | |
model.add(Dense(first, input_shape=shape)) | |
for neurons in hidden: | |
model.add(Dense(neurons, activation=activation)) | |
out_activation = 'sigmoid' if n_classes == 2 else 'softmax' | |
out_units = 1 if n_classes == 2 else n_classes | |
model.add(Dense(out_units, activation=out_activation)) | |
return model | |
def main(): | |
hidden_neurons = [ 650//30 ] * 14 | |
m = mlp(50, n_classes=2, first=650//20, hidden=hidden_neurons, activation='tanh') | |
m.summary() | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python temp/minimlp.py | |
Using TensorFlow backend. | |
_________________________________________________________________ | |
Layer (type) Output Shape Param # | |
================================================================= | |
dense_1 (Dense) (None, 50, 32) 64 | |
_________________________________________________________________ | |
dense_2 (Dense) (None, 50, 21) 693 | |
_________________________________________________________________ | |
dense_3 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_4 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_5 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_6 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_7 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_8 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_9 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_10 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_11 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_12 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_13 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_14 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_15 (Dense) (None, 50, 21) 462 | |
_________________________________________________________________ | |
dense_16 (Dense) (None, 50, 1) 22 | |
================================================================= | |
Total params: 6,785 | |
Trainable params: 6,785 | |
Non-trainable params: 0 | |
_________________________________________________________________ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment