Hi, Ray,
Thanks for the help! I have data like
train.head()
ProbeID words mrFastCount Slope
0 AX-169355813 tatg atga tgac gacc accc ccct cctg ctga tgaa g… 0.04 0.428
1 AX-16629260 gaca acat catt attt tttt tttt tttg ttgg tgga g… 0.10 0.613
2 AX-169451789 ctct tcta ctag tagc agcg gcgt cgtg gtgg tggg g… 0.01 0.535
3 AX-169436214 tgcc gcca ccaa caat aatg atgc tgca gcat catg a… 0.05 0.235
4 AX-169450602 tcag cagt agtt gttt tttc ttca tcaa caac aaca a… 0.01 0.439
train.shape
(76373, 4)
X is based on column words only. It will go through the RNN model.
X[0:3,]
array([[110, 34, 154, 207, 209, 191, 79, 55, 20, 177, 71, 165, 195,
97, 7, 177, 28, 39, 18, 12, 44, 100, 155, 38, 152, 83,
59],
[128, 40, 31, 5, 3, 3, 17, 96, 48, 87, 159, 77, 183,
86, 66, 104, 80, 21, 52, 65, 136, 176, 143, 119, 101, 27,
102],
[ 61, 105, 195, 196, 225, 244, 213, 131, 85, 122, 203, 128, 59,
32, 49, 202, 67, 37, 113, 73, 193, 215, 235, 216, 141, 187,
146]], dtype=int32)
X.shape
(76373, 27)
train_y = np.array(train.Slope)
max_length=27
embedding_dim = 10
gru_dim=12
dense_dim = 6
NUM_EPOCHS = 50
BATCH_SIZE=128
#model architecture*****
in1 = tf.keras.layers.Input(shape=(max_length,))
in2 = tf.keras.layers.Input(shape=(1,)) # for the known variable --mrFastCount I want to add in the concatenate layer.
x = tf.keras.layers.Embedding(vocab_size, embedding_dim, input_length=max_length)(in1)
x = tf.keras.layers.Bidirectional(tf.keras.layers.GRU(gru_dim,dropout=0.4))(x)
x = tf.keras.layers.Dense(dense_dim, activation=‘relu’)(x)
x = tf.keras.layers.concatenate()([x, in2])
out = tf.keras.layers.Dense(1)(x)
model_gru = tf.keras.models.Model(inputs=[in1, in2], outputs=out)
Set the training parameters
optimizer=tf.keras.optimizers.RMSprop(0.001)
model_gru.compile(loss=tf.keras.losses.Huber(), optimizer=optimizer, metrics=[‘mae’])
Print the model summary
model_gru.summary()
Train the model
history_gru = model_gru.fit([X, train.mrFastCount], train_y, batch_size=BATCH_SIZE, epochs=NUM_EPOCHS, validation_data=([val_padded, valid.mrFastCount], val_y))
I got the following error:
ValueError: Layer “model” expects 2 input(s), but it received 1 input tensors. Inputs received: [<tf.Tensor ‘IteratorGetNext:0’ shape=(None, 27) dtype=int32>]
What is wrong? Thanks