MCPcopy
hub / github.com/hanzhanggit/StackGAN / param_init_gru

Function param_init_gru

misc/skipthoughts.py:343–365  ·  view source on GitHub ↗

parameter init for GRU

(options, params, prefix='gru', nin=None, dim=None)

Source from the content-addressed store, hash-verified

341
342
343def param_init_gru(options, params, prefix='gru', nin=None, dim=None):
344 """
345 parameter init for GRU
346 """
347 if nin == None:
348 nin = options['dim_proj']
349 if dim == None:
350 dim = options['dim_proj']
351 W = numpy.concatenate([norm_weight(nin,dim),
352 norm_weight(nin,dim)], axis=1)
353 params[_p(prefix,'W')] = W
354 params[_p(prefix,'b')] = numpy.zeros((2 * dim,)).astype('float32')
355 U = numpy.concatenate([ortho_weight(dim),
356 ortho_weight(dim)], axis=1)
357 params[_p(prefix,'U')] = U
358
359 Wx = norm_weight(nin, dim)
360 params[_p(prefix,'Wx')] = Wx
361 Ux = ortho_weight(dim)
362 params[_p(prefix,'Ux')] = Ux
363 params[_p(prefix,'bx')] = numpy.zeros((dim,)).astype('float32')
364
365 return params
366
367
368def gru_layer(tparams, state_below, options, prefix='gru', mask=None, **kwargs):

Callers

nothing calls this directly

Calls 3

norm_weightFunction · 0.85
_pFunction · 0.85
ortho_weightFunction · 0.85

Tested by

no test coverage detected