mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-03 21:24:11 +03:00
Don't overwrite model in initialization, when loading
This commit is contained in:
parent
99316fa631
commit
8de9829f09
|
@ -19,6 +19,8 @@ import numpy
|
||||||
|
|
||||||
|
|
||||||
def _init_for_precomputed(W, ops):
|
def _init_for_precomputed(W, ops):
|
||||||
|
if (W**2).sum() != 0.:
|
||||||
|
return
|
||||||
reshaped = W.reshape((W.shape[1], W.shape[0] * W.shape[2]))
|
reshaped = W.reshape((W.shape[1], W.shape[0] * W.shape[2]))
|
||||||
ops.xavier_uniform_init(reshaped)
|
ops.xavier_uniform_init(reshaped)
|
||||||
W[:] = reshaped.reshape(W.shape)
|
W[:] = reshaped.reshape(W.shape)
|
||||||
|
@ -247,6 +249,7 @@ def doc2feats(cols=None):
|
||||||
model.cols = cols
|
model.cols = cols
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
|
||||||
def print_shape(prefix):
|
def print_shape(prefix):
|
||||||
def forward(X, drop=0.):
|
def forward(X, drop=0.):
|
||||||
return X, lambda dX, **kwargs: dX
|
return X, lambda dX, **kwargs: dX
|
||||||
|
|
Loading…
Reference in New Issue
Block a user