Hello, I am having trouble getting a prediction for set of accelerometer data from predict_on_batch function of keras.RandomForestModel.
This is the line on which exception occurs:
#test prediction for an example of data input
print(model.predict_on_batch(np.array([1.008, 1.015, 0.017, 1.177, 0.878, 0.916, 1.384, 0.77, 0.77, 0.207, 0.207, 0.081], dtype=np.float32).reshape((1,12))))
This is the stack trace:
AssertionError Traceback (most recent call last)
in ()
56
57 #test prediction for an example of data input
—> 58 print(model.predict_on_batch(np.array([1.008, 1.015, 0.017, 1.177, 0.878, 0.916, 1.384, 0.77, 0.77, 0.207, 0.207, 0.081], dtype=np.float32).reshape((1,12))))
2 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
1145 except Exception as e: # pylint:disable=broad-except
1146 if hasattr(e, “ag_error_metadata”):
→ 1147 raise e.ag_error_metadata.to_exception(e)
1148 else:
1149 raise
AssertionError: in user code:
File "/usr/local/lib/python3.7/dist-packages/tensorflow_decision_forests/keras/core.py", line 621, in run_step *
outputs = model.predict_step(data)
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1751, in predict_step **
return self(x, training=False)
File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
AssertionError: Exception encountered when calling layer "random_forest_model_11" (type RandomForestModel).
in user code:
File "/usr/local/lib/python3.7/dist-packages/tensorflow_decision_forests/keras/core.py", line 791, in call *
normalized_inputs = self._build_normalized_inputs(inputs)
File "/usr/local/lib/python3.7/dist-packages/tensorflow_decision_forests/keras/core.py", line 747, in _build_normalized_inputs *
assert len(self._semantics) == 1
AssertionError:
Call arguments received:
• inputs=tf.Tensor(shape=(1, 12), dtype=float32)
• training=False
Does anyone know how I can solve this error? I have been looking for a solution, but haven’t found it yet.