Exemple #1
0
def test_reset_states():
    obj = GeometricMean()
    obj.update_state([1, 2, 3, 4, 5])
    obj.reset_states()
    assert obj.total.numpy() == 0.0
    assert obj.count.numpy() == 0.0
Exemple #2
0
def test_scalar_update_state_gmean(values, expected):
    obj = GeometricMean()
    values = tf.constant(values, tf.float32)
    for v in values:
        obj.update_state(v)
    check_result(obj, expected, len(values))
Exemple #3
0
def test_vector_update_state_gmean(values, expected):
    obj = GeometricMean()
    values = tf.constant(values, tf.float32)
    obj.update_state(values)
    check_result(obj, expected, len(values))
Exemple #4
0
def test_sample_weight_gmean(values, sample_weight, expected):
    obj = GeometricMean()
    obj.update_state(values, sample_weight=sample_weight)
    assert_result(expected, obj.result().numpy())