Numpy numeric type conversion

Hello. Is there any useful documentation I can take a look at to help me return the metrics as a numpy numeric type?

Thank you.

There’s a flag called run_eagerly in Model compile method. You can set this to True and get a hold of numpy arrays if they’re passed as inputs. Use this to return numpy type output as well. Here’s an example

xs = np.asarray(...)
ys = np.asarray(...)

def custom_mean_absolute_error(y_true, y_pred):
    return np.mean(np.abs(y_true - y_pred))

model = Model(...)
model.compile(loss=...,
	optimizer=...,
	run_eagerly=True,
	metrics=[custom_mean_absolute_error, ...])

model.fit(xs, ys, epochs=...)

If you want to return the result of an existing metric funciton output as numpy, use .numpy() after it.
Here’s an example:
tf.keras.metrics.mean_squared_error(...).numpy()