How do I fix TensorFlow/Keras error : "ValueError: Value returned by __array__ is not a NumPy array"
I'm following the ML course "Create and implement machine learning models" - Create machine learning models
Section - Train and evaluate deep learning models
Unit 3 - Exercise - Train a deep neural network, under sub section "Train a deep neural network model"
Using the notebook: 05a - Deep Neural Networks (TensorFlow).ipynb
Section "Train the model"
initially I had the following error which I fixed:
opt = optimizers.Adam(lr=learning_rate) --> ValueError: Argument(s) not recognized: {'lr': 0.001}
changed to --> opt = optimizers.Adam(learning_rate)
now getting the error "ValueError: Value returned by array is not a NumPy array". I've not changed the data sample and using the core code that was downloaded from github as per instruction in the course.
I've inspected all the variables going used to call the fit function (x_train, y_train, x_test, y_test) and they see me to be correct data type.
Below is the stack trace :
ValueError Traceback (most recent call last)
Cell In[9], line 11
9 # Train the model over 50 epochs using 10-observation batches and using the test holdout dataset for validation
10 num_epochs = 50
---> 11 history = model.fit(x_train, y_train, epochs=num_epochs, batch_size=10, validation_data=(x_test, y_test))
File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
119 filtered_tb = _process_traceback_frames(e.__traceback__)
120 # To get the full stack trace, call:
121 # `keras.config.disable_traceback_filtering()`
--> 122 raise e.with_traceback(filtered_tb) from None
123 finally:
124 del filtered_tb
File /anaconda/envs/azureml_py38/lib/python3.10/site-packages/tensorflow/python/framework/constant_op.py:108, in convert_to_eager_tensor(value, ctx, dtype)
106 dtype = dtypes.as_dtype(dtype).as_datatype_enum
107 ctx.ensure_initialized()
--> 108 return ops.EagerTensor(value, ctx.device_name, dtype)
This question is related to the following Learning Module