[英]How to record the values of a tensor during training in Keras?
I have a customized layer in Keras, and I want to monitor a specific tensor during the training (ie, evaluate this tensor per epoch, and record the value to a list). 我在Keras中有一个定制的层,我想在训练期间监视特定的张量(即,每个时期评估该张量,并将值记录到列表中)。 What should I do to achieve this?
我该怎么做才能做到这一点?
A piece of code as an example: 以一段代码为例:
class customizedLayer(Layer):
def __init__():
...
def build():
...
def call():
tensor_1 = ...
tensor_2 = ...
return ...
output = customizedLayer(input)
model = Model(input=X, output=Y)
model.compile(...)
model.fit(...)
what should I do to get the values of tensor_1 or tensor_2 shown above? 如何获得上面显示的tensor_1或tensor_2的值?
Many thanks. 非常感谢。
You may implement a Callback object to save that values to a file each epoch I think. 您可以实现一个Callback对象,以将每个我认为的值保存到文件中。 If I've got something more specific I'm telling you.
如果我有更具体的事情,我要告诉你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.