Skip to content

Introducing Val_data in Fit function #44

@pascoa-pand

Description

@pascoa-pand

Hello guys,

I was trying NSL out, but I was unable to run .fit with my validation data. What is the correct way to do it?

The following seems to be working just fine:
adv_model.fit({'feature': Xtrain_array, 'label': Ytrain_array},epochs=20)

  • Xtrain_array is a np.array (shape= (20410, 70, 7, 1))
  • Ytrain_array is a np.array (shape= (20410,4))

I tried converting the training and test arrays to a Dataset class using the following code but I'm getting an error "KeyError: 'feature'":

x_train=Xtrain_array
y_train=Ytrain_array
x_val=Xtest_array
y_val=Ytest_array
batch_size=32
train_data = tf.data.Dataset.from_tensor_slices({'input': x_train, 'label': y_train}).batch(batch_size)
val_data = tf.data.Dataset.from_tensor_slices({'input': x_val, 'label': y_val}).batch(batch_size)
val_steps = x_val.shape[0] / batch_size
adv_model.fit(train_data, validation_data=val_data,validation_steps=val_steps, epochs=2, verbose=1)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions