Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Keras input tensor from model

Tags:

keras

I'm working through the Keras example for a sequence to sequence model.

https://github.com/keras-team/keras/blob/master/examples/lstm_seq2seq.py

In this example, they build a model from an input tensor.

encoder_inputs = Input(shape=(None, num_encoder_tokens))
model = Model([encoder_inputs, decoder_inputs], decoder_outputs)
print(encoder_inputs)

output:

Tensor("input_1:0", shape=(?, ?, 71), dtype=float32)

Once a model is built, is there a way to retrieve the input tensor from the model? Something along the lines of

encoder_inputs = model.layers[0].??????
like image 592
Troy D Avatar asked Oct 12 '18 19:10

Troy D


1 Answers

Yes, this is simply model.input or model.inputs

like image 81
Dr. Snoopy Avatar answered Jan 01 '23 08:01

Dr. Snoopy