@@ -9,10 +9,11 @@ class RBM(object):
99
1010 def __init__ (self , input = None , n_visible = 1024 , n_hidden = 1024 ,
1111 W = None , hbias = None , vbias = None , numpy_rng = None ,
12- theano_rng = None ):
12+ theano_rng = None , activation = T . nnet . sigmoid ):
1313
1414 self .n_visible = n_visible
1515 self .n_hidden = n_hidden
16+ self .activation = activation
1617
1718 if numpy_rng is None :
1819 numpy_rng = numpy .random .RandomState (1234 )
@@ -66,7 +67,7 @@ def free_energy(self, v_sample):
6667 def propup (self , vis ):
6768 ''' Propagate the visible activations up to the hidden units '''
6869 pre_sigmoid_activation = T .dot (vis , self .W ) + self .hbias
69- return [pre_sigmoid_activation , T . nnet . sigmoid (pre_sigmoid_activation )]
70+ return [pre_sigmoid_activation , self . activation (pre_sigmoid_activation )]
7071
7172 def sample_h_given_v (self , v0_sample ):
7273 ''' Generates hidden unit outputs given visible inputs '''
@@ -81,7 +82,7 @@ def sample_h_given_v(self, v0_sample):
8182 def propdown (self , hid ):
8283 '''Propagates the hidden activation downwards to the visible units'''
8384 pre_sigmoid_activation = T .dot (hid , self .W .T ) + self .vbias
84- return [pre_sigmoid_activation , T . nnet . sigmoid (pre_sigmoid_activation )]
85+ return [pre_sigmoid_activation , self . activation (pre_sigmoid_activation )]
8586
8687 def sample_v_given_h (self , h0_sample ):
8788 ''' Generates visible units given hidden units '''
@@ -136,11 +137,15 @@ class GBRBM(RBM):
136137 """Gaussian-bernoulli restricted Boltzmann machine"""
137138
138139 def __init__ (self , input = None , n_visible = 351 , n_hidden = 1000 ,
139- W = None , hbias = None , vbias = None ,
140- numpy_rng = None , theano_rng = None ):
140+ W = None , hbias = None , vbias = None , numpy_rng = None ,
141+ theano_rng = None ,activation = T . nnet . sigmoid ):
141142
142- super (GBRBM , self ).__init__ (input = input , n_visible = n_visible , n_hidden = n_hidden ,
143- W = W , hbias = hbias , vbias = vbias , numpy_rng = numpy_rng , theano_rng = theano_rng )
143+ super (GBRBM , self ).__init__ (input = input , n_visible = n_visible ,
144+ n_hidden = n_hidden ,
145+ W = W , hbias = hbias ,
146+ vbias = vbias , numpy_rng = numpy_rng ,
147+ theano_rng = theano_rng ,
148+ activation = activation )
144149
145150 def free_energy (self , v_sample ):
146151 ''' Compute the free energy '''
0 commit comments