本文整理汇总了Python中misc.random_weight_matrix函数的典型用法代码示例。如果您正苦于以下问题:Python random_weight_matrix函数的具体用法?Python random_weight_matrix怎么用?Python random_weight_matrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_weight_matrix函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, L0, D0, U0=None,
alpha=0.005, rseed=10, bptt=1):
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
self.ddim = D0.shape[0] # doc size
param_dims = dict(H = (self.hdim, self.hdim),
U = L0.shape, G = L0.shape)
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape, D = D0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
self.bptt = bptt
self.alpha = alpha
# Initialize word vectors
self.sparams.L = L0.copy()
self.sparams.D = D0.copy()
self.params.U = random.randn(self.vdim, self.hdim)*0.1
# Initialize H matrix, as with W and U in part 1
self.params.H = random_weight_matrix(self.hdim, self.hdim)
self.params.G = random_weight_matrix(self.vdim, self.hdim)
开发者ID:afgiel,项目名称:docvec,代码行数:26,代码来源:drnnlm.py
示例2: __init__
def __init__(self, hdim, outdim, alpha=.005, rho=.0001, rseed=10):
# Dimensions
self.hdim = hdim
self.outdim = outdim
self.out_end = outdim # the end token
# Parameters
np.random.seed(rseed)
# Learning rate
self.alpha = alpha
# Regularization
self.rho = rho
## Theano stuff
# Params as theano.shared matrices
self.Wh = shared(random_weight_matrix(hdim, hdim), name='Wh')
self.U = shared(random_weight_matrix(outdim, hdim), name='U')
self.b = shared(np.zeros([outdim, 1]), name='b', broadcastable=(False, True))
self.params = [self.Wh, self.U, self.b]
self.vparams = [0.0*param.get_value() for param in self.params]
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:26,代码来源:rnn_dec.py
示例3: __init__
def __init__(self, hdim, outdim,
alpha=0.005, rho = 0.0001, rseed=10):
# Dimensions
self.hdim = hdim
self.outdim = outdim
# Parameters
np.random.seed(rseed)
sigma = .1
self.params = {}
#self.params['L'] = np.random.normal(0, sigma, (wdim, vdim)) # "wide" array
self.params['Wh'] = random_weight_matrix(hdim, hdim)
#self.params['Wx'] = random_weight_matrix(hdim, wdim)
# for now, not using xs
self.params['b1'] = np.zeros(hdim)
self.params['U'] = random_weight_matrix(outdim, hdim)
self.params['b2'] = np.zeros(outdim)
# Learning rate
self.alpha = alpha
# Regularization
self.rho = rho
# Store hs and yhats
self.hs = None
self.yhats = None
# grads
self.grads = {}
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:32,代码来源:dec.py
示例4: __init__
def __init__(self, hdim, outdim, alpha=.005, rho=.0001, rseed=10):
# Dimensions
self.hdim = hdim
self.outdim = outdim
self.out_end = outdim # the end token
# Parameters
np.random.seed(rseed)
# Learning rate
self.alpha = alpha
# Regularization
self.rho = rho
## Theano stuff
# Params as theano.shared matrices
# W: times character-vector, U: times previous-hidden-vector
# i: input, f: forget, o: output, c: new-cell
self.Uz = shared(random_weight_matrix(hdim, hdim), name='Uz')
self.Ur = shared(random_weight_matrix(hdim, hdim), name='Ur')
self.Uh = shared(random_weight_matrix(hdim, hdim), name='Uh')
self.U = shared(random_weight_matrix(outdim, hdim), name='U')
self.b = shared(np.zeros([outdim, 1]), name='b', broadcastable=(False, True))
self.params = [self.Uz, self.Ur, self.Uh, self.U, self.b]
self.vparams = [0.0*param.get_value() for param in self.params]
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:30,代码来源:new_dec.py
示例5: __init__
def __init__(self, L0, U0=None,alpha=0.005, lreg = 0.00001, rseed=10, bptt=1):
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
param_dims = dict(H = (self.hdim, self.hdim), W = (self.hdim,self.hdim))
#,U = L0.shape)
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
self.alpha = alpha
self.lreg = lreg
#### YOUR CODE HERE ####
# Initialize word vectors
# either copy the passed L0 and U0 (and initialize in your notebook)
# or initialize with gaussian noise here
# Initialize H matrix, as with W and U in part 1
self.bptt = bptt
random.seed(rseed)
self.params.H = random_weight_matrix(*self.params.H.shape)
self.params.W = random_weight_matrix(*self.params.W.shape)
#self.params.U = 0.1*np.random.randn(*L0.shape)
self.sparams.L = L0.copy()
开发者ID:alphadl,项目名称:cs224d,代码行数:25,代码来源:rnnlmWithHierarchicalSoftmax.py
示例6: __init__
def __init__(self, vdim, hdim, wdim, alpha=.005, rho=.0001, rseed=10):
# Dimensions
self.vdim = vdim
self.hdim = hdim
self.wdim = wdim
# Parameters
np.random.seed(rseed)
# Learning rate
self.alpha = alpha
# Regularization
self.rho = rho
## Theano stuff
# Params as theano.shared matrices
self.L = shared(random_weight_matrix(wdim, vdim), name='L')
self.Wx = shared(random_weight_matrix(hdim, wdim), name='Wx')
self.Wh = shared(random_weight_matrix(hdim, hdim), name='Wh')
self.params = [self.L, self.Wx, self.Wh]
self.vparams = [0.0*param.get_value() for param in self.params]
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:27,代码来源:rnn_enc.py
示例7: __init__
def __init__(self, L0, U0=None,
alpha=0.005, rseed=10):
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
param_dims = dict(LH = (self.hdim, self.hdim),
RH = (self.hdim, self.hdim),
U = (self.vdim, self.hdim * 2))
# note that only L gets sparse updates
param_dims_sparse = dict(LL = L0.shape, RL = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
np.random.seed(rseed) # be sure to seed this for repeatability!
self.alpha = alpha
# Initialize word vectors
# either copy the passed L0 and U0 (and initialize in your notebook)
# or initialize with gaussian noise here
#self.sparams.LL = np.random.randn(*L0.shape) * np.sqrt(0.1)
#self.sparams.RL = np.random.randn(*L0.shape) * np.sqrt(0.1)
self.sparams.LL = L0
self.sparams.RL = L0
self.params.U = np.random.randn(self.vdim, self.hdim*2) * np.sqrt(0.1)
# Initialize H matrix, as with W and U in part 1
self.params.LH = random_weight_matrix(self.hdim, self.hdim)
self.params.RH = random_weight_matrix(self.hdim, self.hdim)
开发者ID:nishithbsk,项目名称:SentenceGeneration,代码行数:28,代码来源:brnnlm.py
示例8: __init__
def __init__(self, L0, Dy=N_ASPECTS*SENT_DIM, U0=None,
alpha=0.005, rseed=10, bptt=5):
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
self.ydim = Dy
param_dims = dict(H = (self.hdim, self.hdim),
U = (self.ydim, self.hdim),
b1 = (self.hdim,),
b2 =(self.ydim,))
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
var = .1
sigma = sqrt(var)
from misc import random_weight_matrix
random.seed(rseed)
# Initialize word vectors
self.bptt = bptt
self.alpha = alpha
self.params.H=random_weight_matrix(*self.params.H.shape)
if U0 is not None:
self.params.U= U0.copy()
else:
self.params.U= random_weight_matrix(*self.params.U.shape)
self.sparams.L = L0.copy()
self.params.b1 = zeros((self.hdim,))
self.params.b2 = zeros((self.ydim,))
开发者ID:laisun,项目名称:EntitySentiment,代码行数:30,代码来源:rnn_simple.py
示例9: __init__
def __init__(self, vdim, hdim, wdim, outdim=2, alpha=.005, rho=.0001, mu=0.75, rseed=10):
# Dimensions
self.vdim = vdim
self.hdim = hdim
self.wdim = wdim
self.outdim = outdim
# Parameters
np.random.seed(rseed)
# Learning rate
self.alpha = alpha
self.mu = mu
self.rho = rho
self.rseed = rseed
## Theano stuff
# Params as theano.shared matrices
self.L = shared(random_weight_matrix(wdim, vdim), name='L')
# W: times character-vector, U: times previous-hidden-vector
self.Wx = shared(random_weight_matrix(hdim, wdim), name='Wx')
self.Wh = shared(random_weight_matrix(wdim, wdim), name='Wh')
self.U = shared(random_weight_matrix(outdim, hdim), name='U')
self.b = shared(np.zeros([outdim, 1]), name='b', broadcastable=(False, True))
self.params = [self.L, self.Wx, self.Wh, self.U, self.b]
self.vparams = [0.0*param.get_value() for param in self.params]
self.prop_compiled = self.compile_self()
self.generate_compiled = self.compile_generate()
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:33,代码来源:d_rnn.py
示例10: __init__
def __init__(self, vdim, hdim, wdim, alpha=.005, rho=.0001, rseed=10):
# Dimensions
self.vdim = vdim
self.hdim = hdim
self.wdim = wdim
# Parameters
np.random.seed(rseed)
# Learning rate
self.alpha = alpha
# Regularization
self.rho = rho
## Theano stuff
# Params as theano.shared matrices
self.L = shared(random_weight_matrix(wdim, vdim), name='L')
# W: times character-vector, U: times previous-hidden-vector
# i: input, f: forget, o: output, c: new-cell
self.Wi = shared(random_weight_matrix(hdim, wdim), name='Wi')
self.Ui = shared(random_weight_matrix(hdim, hdim), name='Ui')
self.Wf = shared(random_weight_matrix(hdim, wdim), name='Wf')
self.Uf = shared(random_weight_matrix(hdim, hdim), name='Uf')
self.Wo = shared(random_weight_matrix(hdim, wdim), name='Wo')
self.Uo = shared(random_weight_matrix(hdim, hdim), name='Uo')
self.Wc = shared(random_weight_matrix(hdim, wdim), name='Wc')
self.Uc = shared(random_weight_matrix(hdim, hdim), name='Uc')
self.params = [self.L, self.Wi, self.Ui, self.Wf, self.Uf, self.Wo, self.Uo, self.Wc, self.Uc]
self.vparams = [0.0*param.get_value() for param in self.params]
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:34,代码来源:lstm_enc.py
示例11: __init__
def __init__(self, wv, windowsize=3,
dims=[None, 100, 5],
reg=0.001, alpha=0.01, rseed=10):
"""
Initialize classifier model.
Arguments:
wv : initial word vectors (array |V| x n)
note that this is the transpose of the n x |V| matrix L
described in the handout; you'll want to keep it in
this |V| x n form for efficiency reasons, since numpy
stores matrix rows continguously.
windowsize : int, size of context window
dims : dimensions of [input, hidden, output]
input dimension can be computed from wv.shape
reg : regularization strength (lambda)
alpha : default learning rate
rseed : random initialization seed
"""
# Set regularization
self.lreg = float(reg)
self.alpha = alpha # default training rate
dims[0] = windowsize * wv.shape[1] # input dimension
param_dims = dict(W=(dims[1], dims[0]),
b1=(dims[1],),
U=(dims[2], dims[1]),
b2=(dims[2],),
)
param_dims_sparse = dict(L=wv.shape)
# initialize parameters: don't change this line
NNBase.__init__(self, param_dims, param_dims_sparse)
random.seed(rseed) # be sure to seed this for repeatability!
#### YOUR CODE HERE ####
# any other initialization you need
#self.sparams, self.grads, self.param, self.sgrads
#where are they defined?
#为什么可以直接可以使用?
self.sparams.L = wv.copy()
#self.sparam.L = wv.copy()
self.params.U = random_weight_matrix(*param_dims["U"])
#self.param.U = random_weight_matrix(param_dims["U"])
self.params.W = random_weight_matrix(*param_dims["W"])
#self.param.b1 = zeros(param_dims["b1"])
#self.param.b2 = zeros(param_dims["b2"])
self.windowSize = windowsize
self.wordVecLen = wv.shape[1]
self.wordVecNum = wv.shape[0]
开发者ID:NeighborhoodWang,项目名称:CS224D-problem-set2,代码行数:52,代码来源:nerwindow.py
示例12: __init__
def __init__(self, wv, windowsize=3,
dims=[None, 100, 5],
reg=0.001, alpha=0.01, rseed=10):
"""
Initialize classifier model.
Arguments:
wv : initial word vectors (array |V| x n)
note that this is the transpose of the n x |V| matrix L
described in the handout; you'll want to keep it in
this |V| x n form for efficiency reasons, since numpy
stores matrix rows continguously.
windowsize : int, size of context window
dims : dimensions of [input, hidden, output]
input dimension can be computed from wv.shape
reg : regularization strength (lambda)
alpha : default learning rate
rseed : random initialization seed
"""
# Set regularization
self.lreg = float(reg)
self.alpha = alpha # default training rate
dims[0] = windowsize * wv.shape[1] # input dimension
param_dims = dict(W1=(dims[1], dims[0]), # 100 x 150
b2=(dims[1],), # 100 x 1
W2=(dims[2], dims[1]), # 5 X 100
b3=(dims[2],), # 5 x 1
)
param_dims_sparse = dict(L=wv.shape) # |V| x 50
# initialize parameters: don't change this line
NNBase.__init__(self, param_dims, param_dims_sparse)
random.seed(rseed) # be sure to seed this for repeatability!
#### YOUR CODE HERE ####
self.sparams.L = wv.copy();
self.params.W1 = random_weight_matrix(param_dims['W1'][0], param_dims['W1'][1])
self.params.b2 = append([], random_weight_matrix(param_dims['b2'][0], 1))
self.params.b3 = append([], random_weight_matrix(param_dims['b3'][0], 1))
self.params.W2 = random_weight_matrix(param_dims['W2'][0], param_dims['W2'][1])
self.n = wv.shape[1]
# informational
self.windowsize = windowsize
self.hidden_units = dims[1]
开发者ID:kireet,项目名称:cs224d,代码行数:50,代码来源:nerwindow.py
示例13: __init__
def __init__(self, L0, U0=None,
alpha=0.005, rseed=10, bptt=1):
self.hdim = L0.shape[1] # word vector dimensions |D|
self.vdim = L0.shape[0] # vocab size |V|
param_dims = dict(H = (self.hdim, self.hdim),
U = L0.shape)
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
# Initialize word vectors
# either copy the passed L0 and U0 (and initialize in your notebook)
# or initialize with gaussian noise here
self.sparams.L = 0.1 * random.standard_normal(self.sparams.L.shape)
# self.params.U
self.params.U = 0.1 * random.standard_normal(self.params.U.shape)
# Initialize H matrix, as with W and U in part 1
# self.params.H = random_weight_matrix(*self.params.H.shape)
self.params.H = random_weight_matrix(*self.params.H.shape)
self.bptt = bptt
self.alpha = alpha
开发者ID:icodingc,项目名称:CS224d,代码行数:26,代码来源:rnnlm.py
示例14: __init__
def __init__(self, L0, U0=None,
alpha=0.005, rseed=10, bptt=1):
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
param_dims = dict(H = (self.hdim, self.hdim),
U = L0.shape)
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
# Initialize word vectors
# either copy the passed L0 and U0 (and initialize in your notebook)
# or initialize with gaussian noise here
# Initialize H matrix, as with W and U in part 1
self.sparams.L = L0.copy()
if U0 is None:
self.params.U = random.normal(0, 0.1, param_dims['U'])
else:
self.params.U = U0.copy()
self.params.H = random_weight_matrix(*param_dims['H'])
self.alpha = alpha
# self.rseed = rseed
self.bptt = bptt
开发者ID:ZhengXuxiao,项目名称:DLforNLP,代码行数:27,代码来源:rnnlm.py
示例15: __init__
def __init__(self, L0, U0=None,
alpha=0.005, rseed=10, bptt=1):
random.seed(rseed)
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
param_dims = dict(H = (self.hdim, self.hdim),
U = L0.shape)
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
self.sparams.L = L0.copy()
self.params.H = random_weight_matrix(self.hdim, self.hdim)
self.alpha = alpha
self.bptt = bptt
# Initialize word vectors
# either copy the passed L0 and U0 (and initialize in your notebook)
# or initialize with gaussian noise here
if U0 is not None:
self.params.U = U0.copy()
else:
sigma = 0.1
mu = 0
#self.params.U = random.normal(mu, sigma, (self.vdim, self.hdim))
self.params.U = sigma*random.randn(self.vdim, self.hdim) + mu
开发者ID:janenie,项目名称:rnn_research,代码行数:28,代码来源:rnnlm.py
示例16: __init__
def __init__(self, L0, U0=None,
alpha=0.005, rseed=10, bptt=1):
self.hdim = L0.shape[1] # word vector dimensions
self.vdim = L0.shape[0] # vocab size
param_dims = dict(H = (self.hdim, self.hdim),
U = (L0.shape if U0 is None else U0.shape))
# note that only L gets sparse updates
param_dims_sparse = dict(L = L0.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
#### YOUR CODE HERE ####
self.alpha = alpha
self.bptt = bptt
# Initialize word vectors
# either copy the passed L0 and U0 (and initialize in your notebook)
# or initialize with gaussian noise here
random.seed(rseed)
sigma = sqrt(0.1)
self.sparams.L = random.normal(0, sigma, L0.shape)
self.params.U = random.normal(0, sigma, param_dims['U'])
# Initialize H matrix, as with W and U in part 1
self.params.H = random_weight_matrix(*param_dims['H'])
self.lamb = .0001 # regularization
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:29,代码来源:rnnlm.py
示例17: __init__
def __init__(self, wv, dims=[100, 5],
reg=0.1, alpha=0.001,
rseed=10):
"""
Set up classifier: parameters, hyperparameters
"""
##
# Store hyperparameters
self.lreg = reg # regularization
self.alpha = alpha # default learning rate
self.nclass = dims[1] # number of output classes
##
# NNBase stores parameters in a special format
# for efficiency reasons, and to allow the code
# to automatically implement gradient checks
# and training algorithms, independent of the
# specific model architecture
# To initialize, give shapes as if to np.array((m,n))
param_dims = dict(W = (dims[1], dims[0]), # 5x100 matrix
b = (dims[1])) # column vector
# These parameters have sparse gradients,
# which is *much* more efficient if only a row
# at a time gets updated (e.g. word representations)
param_dims_sparse = dict(L=wv.shape)
NNBase.__init__(self, param_dims, param_dims_sparse)
##
# Now we can access the parameters using
# self.params.<name> for normal parameters
# self.sparams.<name> for params with sparse gradients
# and get access to normal NumPy arrays
self.sparams.L = wv.copy() # store own representations
self.params.W = random_weight_matrix(*self.params.W.shape)
开发者ID:kornev,项目名称:cs224d-hw2,代码行数:34,代码来源:softmax_example.py
示例18: __init__
def __init__(self, wv, windowsize=3,
dims=[None, 100, 5],
reg=0.001, alpha=0.01, rseed=10):
"""
Initialize classifier model.
Arguments:
wv : initial word vectors (array |V| x n)
note that this is the transpose of the n x |V| matrix L
described in the handout; you'll want to keep it in
this |V| x n form for efficiency reasons, since numpy
stores matrix rows continguously.
windowsize : int, size of context window
dims : dimensions of [input, hidden, output]
input dimension can be computed from wv.shape
reg : regularization strength (lambda)
alpha : default learning rate
rseed : random initialization seed
"""
# Set regularization
self.lreg = float(reg)
self.alpha = alpha # default training rate
#wv.shape: (100232,50)
dims[0] = windowsize * wv.shape[1] # input dimension 3*50=150
param_dims = dict(W=(dims[1], dims[0]),# W(100,150)
b1=(dims[1],),#b(100)
U=(dims[2], dims[1]),#U(5,100)
b2=(dims[2],),#(5,)
)
param_dims_sparse = dict(L=wv.shape) #L(100232,50)
# initialize parameters: don't change this line
NNBase.__init__(self, param_dims, param_dims_sparse)
random.seed(rseed) # be sure to seed this for repeatability!
#### YOUR CODE HERE ####
# any other initialization you need
self.sparams.L = wv.copy() # store own representations,100232,50 matrix
self.params.W = random_weight_matrix(*self.params.W.shape)
self.params.U = random_weight_matrix(*self.params.U.shape)
self.window_size = windowsize#3
self.word_vec_size = wv.shape[1]#50
开发者ID:Tang7,项目名称:rnn224,代码行数:46,代码来源:nerwindow.py
示例19: __init__
def __init__(self, vdim, hdim, wdim, alpha=.005, rho=.0001, rseed=10):
# Dimensions
self.vdim = vdim
self.hdim = hdim
self.wdim = wdim
# Parameters
np.random.seed(rseed)
# Learning rate
self.alpha = alpha
# Regularization
self.rho = rho
## Theano stuff
# Params as theano.shared matrices
self.L = shared(random_weight_matrix(wdim, vdim), name='L')
# W: times character-vector, U: times previous-hidden-vector
# z: update, r: reset, h: new memory content (my notation)
self.Wz = shared(random_weight_matrix(hdim, wdim), name='Wz')
self.Uz = shared(random_weight_matrix(hdim, hdim), name='Uz')
self.Wr = shared(random_weight_matrix(hdim, wdim), name='Wr')
self.Ur = shared(random_weight_matrix(hdim, hdim), name='Ur')
self.Wh = shared(random_weight_matrix(hdim, wdim), name='Wh')
self.Uh = shared(random_weight_matrix(hdim, hdim), name='Uh')
self.params = [self.L, self.Wz, self.Uz, self.Wr, self.Ur, self.Wh, self.Uh]
self.vparams = [0.0*param.get_value() for param in self.params]
开发者ID:arthur-tsang,项目名称:EqnMaster,代码行数:32,代码来源:gru_enc.py
示例20: __init__
def __init__(self, wv, windowsize=3,
dims=[None, 100, 5],
reg=0.001, alpha=0.01, rseed=10):
"""
Initialize classifier model.
Arguments:
wv : initial word vectors (array |V| x n) n=50
note that this is the transpose of the n x |V| matrix L
described in the handout; you'll want to keep it in
this |V| x n form for efficiency reasons, since numpy
stores matrix rows continguously.
windowsize : int, size of context window
dims : dimensions of [input, hidden, output]
input dimension can be computed from wv.shape
reg : regularization strength (lambda)
alpha : default learning rate
rseed : random initialization seed
"""
# Set regularization
self.lreg = float(reg)
self.alpha = alpha # default training rate
self.nclass = dims[2]
# input dimension, wv.shape is the dimension of each word vector representation
dims[0] = windowsize * wv.shape[1] # 50*3
param_dims = dict(W=(dims[1], dims[0]), # 100*150
b1=(dims[1]),
U=(dims[2], dims[1]),
b2=(dims[2]))
param_dims_sparse = dict(L=wv.shape) # L.shape = (|V|*50)
# initialize parameters: don't change this line
NNBase.__init__(self, param_dims, param_dims_sparse)
random.seed(rseed) # be sure to seed this for repeatability!
self.params.W = random_weight_matrix(*self.params.W.shape) # 100*150
self.params.U = random_weight_matrix(*self.params.U.shape) # 5*100
#self.params.b1 = zeros((dims[1],)) # 100*1
#self.params.b2 = zeros((self.nclass,)) # 5*1
self.sparams.L = wv.copy()
开发者ID:WenyingLiu,项目名称:cs224d,代码行数:44,代码来源:nerwindow.py
注:本文中的misc.random_weight_matrix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论