本文整理汇总了Python中theano.tensor.shared_randomstreams.RandomStreams.v_unit方法的典型用法代码示例。如果您正苦于以下问题:Python RandomStreams.v_unit方法的具体用法?Python RandomStreams.v_unit怎么用?Python RandomStreams.v_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theano.tensor.shared_randomstreams.RandomStreams
的用法示例。
在下文中一共展示了RandomStreams.v_unit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from theano.tensor.shared_randomstreams import RandomStreams [as 别名]
# 或者: from theano.tensor.shared_randomstreams.RandomStreams import v_unit [as 别名]
def __init__(self, n_v, n_h, inputs, vbias=None,
hbias=None, initial_W=None, v_unit='BIN',
unit_type='LOG'):
'''
v_unit: str, optional, default: 'BIN'
This variable control the output unit of our RBM
The possible value are ['BIN', 'LOG', 'GAUSS']
unit_type: str, optional, default:'LOG'
This variable control the activation function of the unit,
'LIN' -> W.h +b
'LOG' -> sig(W.h +b)
'''
self.type = unit_type
if initial_W is None:
initial_W = np.asarray(np.random.uniform(
low=-4*np.sqrt(6. / (n_v + n_h)),
high=4*np.sqrt(6. / (n_v + n_h)),
size=(n_v, n_h)),
dtype=theano.config.floatX)
if hbias is None:
hbias = theano.shared(value=np.zeros(n_h,
dtype=theano.config.floatX), name='hbias')
if vbias is None:
vbias = theano.shared(value=np.zeros(n_v,
dtype=theano.config.floatX), name='vbias')
e1 = np.zeros((n_v, n_h), dtype=theano.config.floatX)
e2 = np.zeros((n_h, n_v), dtype=theano.config.floatX)
self.inputs = inputs
self.shape = (n_v, n_h)
self.W = theano.shared(value=initial_W, name='W')
self.eps_up = theano.shared(value=e1, name='eps_u')
self.eps_down = theano.shared(value=e2, name='eps_d')
self.vbias = vbias
self.hbias = hbias
np_rng = np.random.RandomState()
theano_rng = RandomStreams(np_rng.randint(2**30))
self.v_type = v_unit
if v_unit is 'LOG':
theano_rng.v_unit = self.log_sample
elif v_unit is 'GAUSS':
theano_rng.v_unit = self.gauss_sample
else:
theano_rng.v_unit = theano_rng.binomial
self.theano_rng = theano_rng
self.params = [self.W, self.vbias, self.hbias]
self.params_ft = [self.eps_up, self.eps_down]
self.hid = theano.function([self.inputs], self.up(self.inputs))