Exemple #1
0
def _get_quantiles_summary():

    qcombiner = analyzers.QuantilesCombiner(num_quantiles=2,
                                            epsilon=0.01,
                                            bucket_numpy_dtype=tf.float32,
                                            always_return_num_quantiles=False,
                                            has_weights=False,
                                            output_shape=None,
                                            include_max_and_min=False,
                                            feature_shape=[1])
    qcombiner.initialize_local_state(tf_config=None)
    accumulator = qcombiner.create_accumulator()
    add_input_op = qcombiner.add_input(accumulator,
                                       [np.array([1.0, 2.0, 3.0])])
    with tf.compat.v1.Session():
        return add_input_op[0]
Exemple #2
0
                l3=np.array([[17.64386, -17.643852]], dtype=np.float32),
                l4=np.array([[47.71353, 47.71353]], dtype=np.float32))
        ],
        expected_outputs=[
            np.array([[5.751478, -5.751478]], dtype=np.float32),
            np.array([[81.16352, 81.16352]], dtype=np.float32),
            np.array([[0.3923474, 0.55972165]], dtype=np.float32),
            np.array([[0.55972165, 0.3923474]], dtype=np.float32)
        ],
    )
]

_QUANTILES_NO_ELEMENTS_TEST = dict(
    testcase_name='ComputeQuantilesNoElements',
    combiner=analyzers.QuantilesCombiner(num_quantiles=5,
                                         epsilon=0.00001,
                                         bucket_numpy_dtype=np.float32,
                                         always_return_num_quantiles=True),
    batches=[
        (np.empty((0, 1), dtype=np.float32), ),
    ],
    expected_outputs=[np.zeros((4, ), dtype=np.float32)],
)

_QUANTILES_EXACT_NO_ELEMENTS_TEST = dict(
    testcase_name='ComputeExactQuantilesNoElements',
    combiner=analyzers.QuantilesCombiner(num_quantiles=5,
                                         epsilon=0.00001,
                                         bucket_numpy_dtype=np.float32,
                                         always_return_num_quantiles=True),
    batches=[
        (np.empty((0, 1), dtype=np.float32), ),
Exemple #3
0
        _make_mean_and_var_accumulator_from_instance([[7, 8, 9, 10, 11, 12]],
                                                     axis=0),
        _make_mean_and_var_accumulator_from_instance(
            [[100, 200, 3000, 17, 27, 53]], axis=0),
    ],
    expected_outputs=[
        np.float32([36., 70., 1004., 10.33333333, 14.33333333, 23.66666667]),
        np.float32(
            [2054., 8456., 1992014., 28.22222222, 86.22222222, 436.22222222]),
    ],
)

_QUANTILES_NO_ELEMENTS_TEST = dict(
    testcase_name='ComputeQuantilesNoElements',
    combiner=analyzers.QuantilesCombiner(num_quantiles=5,
                                         epsilon=0.00001,
                                         bucket_numpy_dtype=np.float32,
                                         always_return_num_quantiles=False),
    batches=[
        (np.empty((0, 1), dtype=np.float32), ),
    ],
    expected_outputs=[np.zeros((0, ), dtype=np.float32)],
)

_QUANTILES_EXACT_NO_ELEMENTS_TEST = dict(
    testcase_name='ComputeExactQuantilesNoElements',
    combiner=analyzers.QuantilesCombiner(num_quantiles=5,
                                         epsilon=0.00001,
                                         bucket_numpy_dtype=np.float32,
                                         always_return_num_quantiles=True),
    batches=[
        (np.empty((0, 1), dtype=np.float32), ),