0

I want to train a Keras model with multiple inputs. I want to use the first input for training the model, but the second and the third inputs are variables which must be used during the training of the first input. I could not use the tf.Variable for using the second and the third inputs which are fixed during the training because it showed the error: You must feed a placeholder. So, I want to feed them using tf.keras. I changed the shape of the second and the third inputs to be similar to the first one. Then, I concatenate them using:

inputs = tf.keras.layers.concatenate([data, masks_rep, ind_rep], axis=2)

Then, for retrieving them in the model, I wrote:

Inputs_t = tf.keras.Input(shape=(max_length, 3*charset_length))
x, m_k_expand, ind_k_expand = tf.split(Inputs_t, num_or_size_splits=3,  axis=1)

But it changes the dimensions of the layers from charset_length to 3*charset_length. How can I solve this problem?

Narcis
  • 441
  • 1
  • 3
  • 12

1 Answers1

0

We can use the subclasses to use additional variables by using tf.Variable. tf.Variable easily leads bugs when it is used with tf.keras.layers. But using subclasses prevents bugs. More examples are provided here: enter link description here

Narcis
  • 441
  • 1
  • 3
  • 12