【问题标题】:Catch output of keras layer捕获keras层的输出
【发布时间】:2017-07-04 14:11:55
【问题描述】:

这是我的神经网络:

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 是此处的自定义指标 我用这个命令来捕捉最后一层的输出(Dense(1))

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

它给了我这个输出:

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

我想要每个训练示例的输出,我该怎么做?

【问题讨论】:

    标签: python-3.x neural-network keras


    【解决方案1】:
    predictions = model.predict(allTrainingExamples)
    

    【讨论】:

      猜你喜欢
      • 2017-05-25
      • 1970-01-01
      • 1970-01-01
      • 2017-06-02
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-06
      相关资源
      最近更新 更多