コード例 #1
0
def binarized2_bn_label():
    image = bn_image()
    image = binarize(image, (0, 1), included_in='lower')
    mean = np.mean(image, axis=(0, 1))
    assert mean.shape == (10,)
    label = np.argmax(mean)
    return label
コード例 #2
0
def binarized_bn_label(bn_image):
    image = bn_image
    image = binarize(image, (0, 1))
    mean = np.mean(image, axis=(0, 1))
    assert mean.shape == (10,)
    label = np.argmax(mean)
    return label
コード例 #3
0
    def preprocessing(x):
        x = binarize(x, (0, 1), included_in='lower')

        def backward(x):
            return x

        return x, backward
コード例 #4
0
    def preprocessing(x):
        x = binarize(x, (0, 1))

        def backward(x):
            return x

        return x, backward
コード例 #5
0
def binarized2_bn_labels(bn_images):
    images = bn_images
    images = binarize(images, (0, 1), included_in="lower")
    means = np.mean(images, axis=(1, 2))
    assert means.shape == (len(images), 10)
    labels = np.argmax(means, -1)
    return labels
コード例 #6
0
def binarized_bn_labels(bn_images):
    images = bn_images
    images = binarize(images, (1, 2))
    means = np.mean(images, axis=(1, 2))
    assert means.shape == (len(bn_images), 10)
    label = np.argmax(means, axis=-1)
    return label
コード例 #7
0
def test_binarize():
    x = np.array([0.1, 0.5, 0.7, 0.4])
    x1 = binarize(x, (-2, 2), 0.5)
    assert np.all(abs(x1) == 2)
    with pytest.raises(ValueError):
        binarize(x, (-2, 2), 0.5, included_in='blabla')