Categories
Misc

ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following input: RaggedTensor

I have following inputs to be train on CNN.

x = np.array(Images)

y = [ [[0]], [[76., 5., 9., 1., 0., 0.], [54., 4., 10., 51.]] ]

Since the ‘y’ input is a n-dimensions array of non-uniform sizes, I used RaggedTensor to represent ‘y’ input and fed it to the network.

y = tf.ragged.constant(y)

cnn_model.fit(x, y, epochs = 10, batch_size=32, validation_split=0.30)

I am receiving following error:

ValueError: validation_split is only supported for Tensors or NumPy arrays, found following types in the input: [<class ‘tensorflow.python.ops.ragged.ragged_tensor.RaggedTensor’>]

If I convert ‘y’ to numpy.ndarray and fit it to the model, I get following error,

cnn_model.fit(x, y.numpy(), epochs = 10, batch_size=32, validation_split=0.30)

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).

I would want to train this input ‘y’ of n-dimensional array to the model, kindly suggest which datatype representation would be suitable regarding this.

submitted by /u/sarvna
[visit reddit] [comments]

Leave a Reply

Your email address will not be published. Required fields are marked *