Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

目前python的api支持网络模型中间各层的输出吗?

Open kolinwei opened this issue 8 years ago • 3 comments

之前使用keras,发现可以通过model.get_layer(...).output()拿到神经网络中具体某一层的输出。

kolinwei avatar Dec 13 '17 08:12 kolinwei

我也是自己折腾找到的,顺便附赠怎样查看参数:

if isinstance(event, paddle.event.EndIteration):
    if event.batch_id % 10 == 0:
        output = event.gm.getLayerOutputs(['fc1','fc2','output'])  #list里是要输出的层的名字
        myparamw = trainer.__parameters__.get('_myparam.w0') #str是参数的名字
        myparamb = trainer.__parameters__.get('_myparam.wbias')

以及如果不正确/有更好的,请这边的各位老师指出来,谢谢!

rulai-huiyingl avatar Dec 14 '17 00:12 rulai-huiyingl

用这个event: paddle.event.EndForwardBackward,如果是GPU训练也可以拿到。

typhoonzero avatar Dec 14 '17 01:12 typhoonzero

如果是预测的时候想拿到各层的输出,怎样实现呢

kolinwei avatar Dec 21 '17 02:12 kolinwei