我不知道为什么我的内存不足。采取
parser
对于戈德堡,我所做的就是改变
this
生产线:
分数,表达式=自我__评估(conll\U语句,真)
并在其周围添加一个for循环,以重复K次:
for k in xrange(K):
scores, exprs = self.__evaluate(conll_sentence, True)
# do something
然后在
getExpr
,我执行以下操作:
samples_out = np.random.normal(0,0.001, (1, self.hidden_units))
samples_FOH = np.random.normal(0,0.001,(self.hidden_units, self.ldims * 2))
samples_FOM = np.random.normal(0,0.001,(self.hidden_units, self.ldims * 2))
samples_Bias = np.random.normal(0,0.001, (self.hidden_units))
XoutLayer = self.outLayer.expr()+inputTensor(samples_out)
XhidLayerFOH = self.hidLayerFOH.expr()+inputTensor(samples_FOH)
XhidLayerFOM = self.hidLayerFOM.expr()+inputTensor(samples_FOM)
XhidBias = self.hidBias.expr()+inputTensor(samples_Bias)
if sentence[i].headfov is None:
sentence[i].headfov = XhidLayerFOH * concatenate([sentence[i].lstms[0], sentence[i].lstms[1]])
if sentence[j].modfov is None:
sentence[j].modfov = XhidLayerFOM * concatenate([sentence[j].lstms[0], sentence[j].lstms[1]])
output = XoutLayer * self.activation(sentence[i].headfov + sentence[j].modfov + XhidBias)
return output
从本质上讲,上述块中发生的事情是首先生成正态分布的噪声,然后将其添加到训练值中。但似乎在整个过程中的某个地方,所有生成的值都保留在内存中,而它只是耗尽了内存。有人知道为什么吗?