I am trying to convert neural networks from a book to Wolfram language. The book has this example with the quote
two layers of 10 neurons and a dropout of 0.2 for each
def create_mlp_2layer():
model_arch = [
Dense(10, activation="relu"),
Dropout(0.2),
Dense(10, activation="relu"),
Dropout(0.2),
Dense(1)
]
model = Sequential(model_arch)
model.compile(optimizer="adam", loss ='mse')
return model
I have used Predict, Classify, and I am conversant with data pre-processing to feed data appropriately. However, I would like to learn this "translation".
As far as I was able to figure out, relu would likely become Ramp[], Dropout(0.2) would become DropoutLayer[0.2],however, I am not clear about how to put everything together. The net should return a real number as the output.
The input is a vector of length 167 which is mostly 0's and a few 1's.
I tried to hack this together, however, I am lost.
NetChain[{LinearLayer[167], ElementwiseLayer[Ramp], DropoutLayer[0.2],
ElementwiseLayer[Ramp], DropoutLayer[0.2], LinearLayer[1]}]
Using NetInitialize on this complains that
Cannot initialize net: unspecified or partially specified shape for array "Weights" of first layer.
It would be great if anyone can show how to translate this to WL syntax to prepare the NN.
Thank you,