<s> import os <EOL> import six <EOL> import numpy as np <EOL> import theano <EOL> import matplotlib . pyplot as plt <EOL> from neupy import plots <EOL> from base import BaseTestCase <EOL> from utils import ( skip_image_comparison_if_specified , image_comparison , <EOL> format_image_name ) <EOL> IMGDIR = os . path . join ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> class HintonDiagramTestCase ( BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( HintonDiagramTestCase , self ) . setUp ( ) <EOL> theano . config . floatX = '<STR_LIT>' <EOL> @ skip_image_comparison_if_specified <EOL> def test_simple_hinton ( self ) : <EOL> original_image_name = format_image_name ( "<STR_LIT>" ) <EOL> original_image = os . path . join ( IMGDIR , original_image_name ) <EOL> with image_comparison ( original_image , figsize = ( <NUM_LIT:10> , <NUM_LIT:6> ) ) as fig : <EOL> weight = np . random . randn ( <NUM_LIT:20> , <NUM_LIT:20> ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> plt . sca ( ax ) <EOL> plots . hinton ( weight , add_legend = True ) <EOL> @ skip_image_comparison_if_specified <EOL> def test_max_weight ( self ) : <EOL> original_image_name = format_image_name ( "<STR_LIT>" ) <EOL> original_image = os . path . join ( IMGDIR , original_image_name ) <EOL> with image_comparison ( original_image , figsize = ( <NUM_LIT:10> , <NUM_LIT:6> ) ) as fig : <EOL> weight = <NUM_LIT:100> * np . random . randn ( <NUM_LIT:20> , <NUM_LIT:20> ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> plots . hinton ( weight , ax = ax , max_weight = <NUM_LIT:10> , add_legend = True ) <EOL> @ skip_image_comparison_if_specified <EOL> def test_hinton_without_legend ( self ) : <EOL> original_image_name = format_image_name ( "<STR_LIT>" ) <EOL> original_image = os . path . join ( IMGDIR , original_image_name ) <EOL> with image_comparison ( original_image , figsize = ( <NUM_LIT:10> , <NUM_LIT:6> ) ) as fig : <EOL> weight = np . random . randn ( <NUM_LIT:20> , <NUM_LIT:20> ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> plots . hinton ( weight , ax = ax , add_legend = False ) <EOL> @ skip_image_comparison_if_specified <EOL> def test_hinton_only_positive ( self ) : <EOL> original_image_name = format_image_name ( "<STR_LIT>" ) <EOL> original_image = os . path . join ( IMGDIR , original_image_name ) <EOL> with image_comparison ( original_image , figsize = ( <NUM_LIT:10> , <NUM_LIT:6> ) ) as fig : <EOL> weight = np . random . random ( ( <NUM_LIT:20> , <NUM_LIT:20> ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> plots . hinton ( weight , ax = ax ) <EOL> @ skip_image_comparison_if_specified <EOL> def test_hinton_only_negative ( self ) : <EOL> original_image_name = format_image_name ( "<STR_LIT>" ) <EOL> original_image = os . path . join ( IMGDIR , original_image_name ) <EOL> with image_comparison ( original_image , figsize = ( <NUM_LIT:10> , <NUM_LIT:6> ) ) as fig : <EOL> weight = - np . random . random ( ( <NUM_LIT:20> , <NUM_LIT:20> ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> plots . hinton ( weight , ax = ax ) <EOL> @ skip_image_comparison_if_specified <EOL> def test_hinton_1darray ( self ) : <EOL> original_image_name = format_image_name ( "<STR_LIT>" ) <EOL> original_image = os . path . join ( IMGDIR , original_image_name ) <EOL> with image_comparison ( original_image , figsize = ( <NUM_LIT:10> , <NUM_LIT:4> ) ) as fig : <EOL> weight = - np . random . randn ( <NUM_LIT:20> ) <EOL> ax = fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> plots . hinton ( weight , ax = ax ) </s>
