我试图通过遵循代码来训练我的模型。
sess.run([train_op, model.global_step, model.loss, model.prediction], feed_dict)但是,当我运行"model.prediction“时,我发现内存使用量会动态增加。
在迭代过程中,我从不保存"sess.run()“的结果。
"model.prediction“是
@property
def prediction(self):
return [tf.argmax(self.logits_b, 1),
tf.argmax(self.logits_m, 1),
tf.argmax(self.logits_s, 1),
tf.argmax(self.logits_d, 1)]我不知道为什么会这样。请帮帮我。
发布于 2018-12-05 15:38:27
每次使用属性prediction时,都要在图形中创建新操作。您应该在此之前只创建一次操作,并在属性中返回它们:
def create_model(self):
# Hypothetical function that creates the model, only called once
# ...
self._prediction = (tf.argmax(self.logits_b, 1),
tf.argmax(self.logits_m, 1),
tf.argmax(self.logits_s, 1),
tf.argmax(self.logits_d, 1))
# ...
@property
def prediction(self):
return self._predictionhttps://stackoverflow.com/questions/53634675
复制相似问题