parameter init for GRU
(options, params, prefix='gru', nin=None, dim=None)
| 341 | |
| 342 | |
| 343 | def 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 | |
| 368 | def gru_layer(tparams, state_below, options, prefix='gru', mask=None, **kwargs): |
nothing calls this directly
no test coverage detected