1
votes

I have a simple sequential neural network which I would like to use to train a classifier. It is made of one input layer, 3 hidden layers and one output layer, as follows:

    #sequential type of model
model = Sequential() 
#stacking layers with .add
model.add(Dense(len(ytrain), activation='relu', input_dim=100))
model.add(Dropout(0.5))
model.add(Dense(len(ytrain), activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(len(ytrain), activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(len(ytrain), activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(5, activation='softmax'))

How can I extract the weights associated with each hidden layer. The ultimate goal is to then use the activation function to compute the probability of each label to be the correct one.

Hope you understand. Any kind of help is appreciated.

1

1 Answers

6
votes
weights = [layer.get_weights() for layer in model.layers]