调用model.predict一次后获取层的张量值
Getting the tensor values of a layer after calling model.predict once
在运行以下代码之后,我如何获得神经网络中某一层的输出激活的张量。
x= model.predict(frame)
这是一个简短的示例,说明如何使用 Keras' functional API:
inputs = Input(shape=(10,))
x = Dense(5)(inputs)
latent_outputs = Dense(2)(x)
x = Dense(5)(latent_outputs)
outputs = Dense(10)(x)
encoder = Model(inputs, latent_outputs)
autoencoder = Model(inputs, outputs)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(np.zeros((10, 10)), np.zeros((10, 10)))
latent_output = encoder.predict(np.zeros((1, 10)))
print(latent_output)
在运行以下代码之后,我如何获得神经网络中某一层的输出激活的张量。
x= model.predict(frame)
这是一个简短的示例,说明如何使用 Keras' functional API:
inputs = Input(shape=(10,))
x = Dense(5)(inputs)
latent_outputs = Dense(2)(x)
x = Dense(5)(latent_outputs)
outputs = Dense(10)(x)
encoder = Model(inputs, latent_outputs)
autoencoder = Model(inputs, outputs)
autoencoder.compile(optimizer='adam', loss='mse')
autoencoder.fit(np.zeros((10, 10)), np.zeros((10, 10)))
latent_output = encoder.predict(np.zeros((1, 10)))
print(latent_output)