I am a beginner in python and Keras. I am using Keras with tensorflow backend. I want to get value in array from each layer (hidden and output layer) in Keras. How can i do it?
This is my sequential model
def baseline_model():
# create model
model = Sequential()
model.add(Conv2D(32, (5, 5), input_shape=(1, 28, 28), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.2))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(num_classes, activation=tempsigmoid))
# Compile model
model.compile(loss='mse', optimizer='adam', metrics=['accuracy'])
return model
# build the model
model = baseline_model()
I had tried using this code
hidden_layer = model.layers[4].output
print(hidden_layer)
but the result in tensor
Tensor("dense_1/Relu:0", shape=(?, 128), dtype=float32)