简体   繁体   中英

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). 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?

Many thanks.

You may implement a Callback object to save that values to a file each epoch I think. If I've got something more specific I'm telling you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM