Tanmay Bhatnagar
Tanmay Bhatnagar

Reputation: 2470

Catch output of keras layer

This is my neural network :

model = Sequential()
act = 'relu'
model.add(Dense(430, input_shape=(3,)))
model.add(Activation(act))

model.add(Dense(256))
model.add(Activation(act))
model.add(Dropout(0.42))

model.add(Dense(148))
model.add(Activation(act))
model.add(Dropout(0.3))

model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=[myAccuracy])

myAccuracy is a custom metric here I used this command to catch the output of the final layer (Dense(1))

output = model.layers[8].output
print(output)

It gave me this output:

Tensor("dense_4/BiasAdd:0", shape=(?, 1), dtype=float32)
0

I want the output for every training example I have how do I do this ?

Upvotes: 0

Views: 31

Answers (1)

Daniel Möller
Daniel Möller

Reputation: 86600

predictions = model.predict(allTrainingExamples)

Upvotes: 2

Related Questions