Esempio n. 1
0
def init_params(options):

    n_chars = options['n_chars']
    n_x = options['n_x']

    params = OrderedDict()
    # character embedding
    params['Wemb'] = uniform_weight(n_chars, n_x)
    # encoding characters into words
    params = param_init_encoder(options, params, prefix='encoder_f')
    params = param_init_encoder(options, params, prefix='encoder_b')

    return params
Esempio n. 2
0
def init_params(options,W):
    
    n_h = options['n_h']
    n_y = options['n_y']
    
    params = OrderedDict()
    # W is initialized by the pretrained word embedding
    params['Wemb'] = W.astype(config.floatX)
    # otherwise, W will be initialized randomly
    # n_words = options['n_words']
    # n_x = options['n_x'] 
    # params['Wemb'] = uniform_weight(n_words,n_x)
    
    # bidirectional LSTM
    params = param_init_encoder(options,params,prefix="lstm_encoder")
    params = param_init_encoder(options,params,prefix="lstm_encoder_rev")
    
    params['Wy'] = uniform_weight(2*n_h,n_y)
    params['by'] = zero_bias(n_y)                                     

    return params
Esempio n. 3
0
def init_params(options, W):

    n_p = options['n_p']
    n_h = options['n_h']
    n_y = options['n_y']

    params = OrderedDict()
    # W is initialized by the pretrained word embedding
    params['Wemb'] = W.astype(config.floatX)
    # otherwise, W will be initialized randomly
    # n_words = options['n_words']
    # n_x = options['n_x']
    # params['Wemb'] = uniform_weight(n_words,n_x)

    # bidirectional LSTM
    #params = param_init_encoder(options,params, prefix="lstm_encoder")
    #params = param_init_encoder(options,params, prefix="lstm_encoder_rev")
    params = param_init_encoder(options, params, prefix="gru_encoder")
    params = param_init_encoder(options, params, prefix="gru_encoder_rev")

    #params['Wy'] = uniform_weight(n_p, 2*n_h+1, scale=0.1)
    params['Wy'] = np.squeeze(uniform_weight(n_p, 2 * n_h, 1))
    return params
def init_params(options, W):

    n_words = options['n_words']
    n_x = options['n_x']
    n_h = options['n_h']
    n_z = options['n_z']

    params = OrderedDict()
    # word embedding
    # params['Wemb'] = uniform_weight(n_words,n_x)
    params['Wemb'] = W.astype(config.floatX)
    params = param_init_encoder(options, params)

    params['Vhid'] = uniform_weight(n_h, n_x)
    params['bhid'] = zero_bias(n_words)

    params['C0'] = uniform_weight(n_z, n_x)

    return params