简体   繁体   中英

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

I'm using KERAS with TensorFlow back-end. 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 )?

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. This can be done like this 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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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