weights values per iteration for ANN in Keras

4106 views neural-network
4

I am trying to output weights values for the last layer of my ANN per iteration. But from the following code I wrote, I could only output it for the last iteration, which means the final result. So how can I add it to per iteration?

model=Sequential()
model.add(Dense(3,activation='sigmoid',input_dim=8))
model.add(Dense(3,activation='sigmoid'))
model.add(Dense(10,activation='softmax'))

sgd=SGD(lr=0.1)
model.compile(optimizer=sgd,loss='categorical_crossentropy',metrics=['accuracy'])

print("Training----------")
model.fit(features_train,class_train,validation_data=(features_test,class_test),nb_epoch=100,batch_size=1)

weights = np.array(model.layers[2].get_weights())
print(weights)

answered question

Have an answer?

JD

Please login first before posting an answer.