简体   繁体   English

从经过训练的模型(Python)中提取拟合的输出(KERAS / TensorFlow)

[英]Extract fitted output from the trained model in Python (KERAS/TensorFlow)

I'm using KERAS with TensorFlow back-end. 我正在使用带有TensorFlow后端的KERAS。 Suppose that this is the model block: 假设这是模型块:

model.add(LSTM(units = 60, activation = 'tanh')
model.add(Dropout(rate = 0.5))
model.add(Dense(units = 1, activation = 'sigmoid'))
model.compile(optimizer = 'adam', loss = 'mse')
model.fit(X_train, Y_train, epochs = 200, batch_size = 32)

Is there any way to extract fitted output from the trained model ( model )? 有什么办法来提取从训练模型(拟合输出model )?

You should probably rephrase you question, as it is not clear what fitted output you try to achieve. 您可能应该重新表述您的问题,因为尚不清楚您尝试实现什么合适的输出。 I guess the most probable scenarios with respect to machine learning is that: 我猜想与机器学习有关的最可能场景是:

  1. You have new input data X , and want to do a prediction with your fitted model. 您有新的输入数据X ,并希望使用拟合模型进行预测。 This can be done like this model.predict(X) . 可以像model.predict(X)这样完成。
  2. Or you are trying to get the weights of the fitted model, which can be done like this model.get_weights() . 或者您正在尝试获取拟合模型的权重,可以像model.get_weights()这样完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM