Custom keras metric with tensorflowflow functions. Uninitialized variables

115 Views Asked by At

I am running a model with a custom metric in tensorflow 1.14, and I have issues with uninitialized variables.

def metric(y_true, y_pred):
    # some math operations all in tensorflow
    # ... 
    return tf.metrics.mean(tf.reduce_sum(my_mat, reduction_indices=[1]) / num_rel)

pred = tf.placeholder(dtype=tf.int32, shape=[None, 1]) 
model.compile(optimizer='adam', loss='mean_squared_error', metrics=[metric], target_tensors=pred)
met.test_on_batch(x, y)

enter image description here

These errors were raised in the metric, and I am hoping that I am just missing something simple. Any help would be appreciated.

0

There are 0 best solutions below