コード例 #1
0
ファイル: test_zca.py プロジェクト: vamsijkrishna/neupy
    def test_simple_zca(self):
        plt.style.use('ggplot')

        original_image_name = format_image_name("simple_zca.png")
        original_image = os.path.join(PLOTS_DIR, original_image_name)
        image = os.path.join(IMGDIR, "cifar10.png")

        data = imread(image)
        data = data[:, :, 0]

        comparison_kwargs = dict(figsize=(10, 6), tol=0.05)

        with image_comparison(original_image, **comparison_kwargs) as fig:
            ax = fig.add_subplot(1, 1, 1)

            zca = preprocessing.ZCA(0.001)
            zca.train(data)
            data_transformed = zca.transform(data)

            ax.imshow(data_transformed, cmap=plt.cm.binary)

        with image_comparison(original_image, **comparison_kwargs) as fig:
            ax = fig.add_subplot(1, 1, 1)

            zca = preprocessing.ZCA(0.001)
            data_transformed = zca.fit(data).transform(data)

            ax.imshow(data_transformed, cmap=plt.cm.binary)
コード例 #2
0
    def test_max_weight(self):
        original_image_name = format_image_name("max_weight_hinton.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = 100 * np.random.randn(20, 20)
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax, max_weight=10, add_legend=True)
コード例 #3
0
ファイル: test_error_plot.py プロジェクト: EdwardBetts/neupy
    def test_log_scale(self):
        original_image_name = format_image_name("log_scale.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image) as fig:
            ax = fig.add_subplot(1, 1, 1)
            network = reproducible_network_train(step=0.3)
            network.plot_errors(logx=True, ax=ax, show=False)
コード例 #4
0
    def test_hinton_only_negative(self):
        original_image_name = format_image_name("hinton_only_negative.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = -np.random.random((20, 20))
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax)
コード例 #5
0
    def test_log_scale(self):
        original_image_name = format_image_name("log_scale.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image) as fig:
            ax = fig.add_subplot(1, 1, 1)
            network = reproducible_network_train(step=0.3)
            plots.error_plot(network, logx=True, ax=ax, show=False)
コード例 #6
0
ファイル: test_hinton.py プロジェクト: EdwardBetts/neupy
    def test_max_weight(self):
        original_image_name = format_image_name("max_weight_hinton.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = 100 * np.random.randn(20, 20)
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax, max_weight=10, add_legend=True)
コード例 #7
0
ファイル: test_error_plot.py プロジェクト: disc5/neupy
    def test_simple_plot(self):
        original_image_name = format_image_name("simple_plot.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image) as fig:
            ax = fig.add_subplot(1, 1, 1)
            network = reproducible_network_train(step=0.3)
            network.plot_errors(ax=ax, show=False)
コード例 #8
0
ファイル: test_error_plot.py プロジェクト: InSertCod3/neupy
    def test_simple_plot(self):
        original_image_name = format_image_name("simple_plot.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image) as fig:
            ax = fig.add_subplot(1, 1, 1)
            network = reproducible_network_train(step=0.3)
            plots.error_plot(network, ax=ax, show=False)
コード例 #9
0
ファイル: test_hinton.py プロジェクト: EdwardBetts/neupy
    def test_hinton_1darray(self):
        original_image_name = format_image_name("hinton_1darray.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 4)) as fig:
            weight = -np.random.randn(20)
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax)
コード例 #10
0
ファイル: test_hinton.py プロジェクト: EdwardBetts/neupy
    def test_hinton_only_negative(self):
        original_image_name = format_image_name("hinton_only_negative.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = -np.random.random((20, 20))
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax)
コード例 #11
0
ファイル: test_hinton.py プロジェクト: EdwardBetts/neupy
    def test_hinton_without_legend(self):
        original_image_name = format_image_name("hinton_without_legend.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = np.random.randn(20, 20)
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax, add_legend=False)
コード例 #12
0
    def test_hinton_without_legend(self):
        original_image_name = format_image_name("hinton_without_legend.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = np.random.randn(20, 20)
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax, add_legend=False)
コード例 #13
0
    def test_hinton_1darray(self):
        original_image_name = format_image_name("hinton_1darray.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 4)) as fig:
            weight = -np.random.randn(20)
            ax = fig.add_subplot(1, 1, 1)
            plots.hinton(weight, ax=ax)
コード例 #14
0
    def test_simple_hinton(self):
        original_image_name = format_image_name("simple_hinton.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = np.random.randn(20, 20)
            ax = fig.add_subplot(1, 1, 1)
            plt.sca(ax)  # To test the case when ax=None
            plots.hinton(weight, add_legend=True)
コード例 #15
0
ファイル: test_hinton.py プロジェクト: EdwardBetts/neupy
    def test_simple_hinton(self):
        original_image_name = format_image_name("simple_hinton.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image, figsize=(10, 6)) as fig:
            weight = np.random.randn(20, 20)
            ax = fig.add_subplot(1, 1, 1)
            plt.sca(ax)  # To test the case when ax=None
            plots.hinton(weight, add_legend=True)
コード例 #16
0
    def test_plot_with_validation_dataset(self):
        original_image_name = format_image_name("with_validation.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image) as fig:
            ax = fig.add_subplot(1, 1, 1)

            x_train, x_test, y_train, y_test = simple_classification()
            gdnet = algorithms.GradientDescent((10, 12, 1), step=0.25)
            gdnet.train(x_train, y_train, x_test, y_test, epochs=100)
            plots.error_plot(gdnet, ax=ax, show=False)
コード例 #17
0
ファイル: test_error_plot.py プロジェクト: EdwardBetts/neupy
    def test_plot_with_validation_dataset(self):
        original_image_name = format_image_name("with_validation.png")
        original_image = os.path.join(IMGDIR, original_image_name)

        with image_comparison(original_image) as fig:
            ax = fig.add_subplot(1, 1, 1)

            x_train, x_test, y_train, y_test = simple_classification()
            gdnet = algorithms.GradientDescent((10, 12, 1), step=0.25)
            gdnet.train(x_train, y_train, x_test, y_test, epochs=100)
            gdnet.plot_errors(ax=ax, show=False)