It is my first GRU model so pardon the stupidity. I am trying to learn by training a simple GRU network on variable length sequences. The sequences are numpy arrays of tensors. The length of numpy array varies from sample to sample. The model generator and fit code is below:
def declare_model(emb_size, gru_size, num_classes):
inputs = keras.Input(shape=(None, emb_size))
gru_out = keras.layers.Bidirectional(keras.layers.GRU(gru_size, return_sequences=False))(inputs)
gru_out = keras.layers.Flatten()(gru_out)
predictions = keras.layers.Dense(num_classes, activation='sigmoid')(gru_out)
model = keras.Model(inputs=inputs, outputs=predictions)
model.compile(optimizer=keras.optimizers.Adam(), loss='binary_crossentropy', metrics=['accuracy'])
return model
m = declare_model(emb_size=200, gru_size=20, num_classes=2)
m.fit(dafr["Data"], dafr["Label"], epochs=100, batch_size=32, validation_split=0.2)
The type of an element of 'dafr["Data"]' is "numpy.ndarray" type of each element of this element is "torch.Tensor" shape of each tensor is "200 {torch. Size([200])}" and dtype of tensor is float. Type of element of 'dafr["Label"]' is 'numpy.int64'. While fitting I am getting error "ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).". Why is this error occurring and how can I resolve it?