djl icon indicating copy to clipboard operation
djl copied to clipboard

How to print model's topology and each block's input/output information (如何打印model 的网络结构)

Open yanchaoguo opened this issue 4 years ago • 3 comments

或者获取每层网络的类型和大小 、输入和输出维度相关信息

yanchaoguo avatar Jun 10 '20 15:06 yanchaoguo

@yanchaoguo We don't support this feature today. We had some prototype, and not mature enough to publish it.

frankfliu avatar Jun 10 '20 16:06 frankfliu

You can manually get those information using Block API:

  1. Each block has inputShape and inputNames variable: https://github.com/awslabs/djl/blob/master/api/src/main/java/ai/djl/nn/AbstractBlock.java#L73-L76
  2. You call Block.getOutputShapes() to get output information: https://github.com/awslabs/djl/blob/master/api/src/main/java/ai/djl/nn/Block.java#L228

frankfliu avatar Jun 10 '20 17:06 frankfliu

I think I can improve this when I refactor the initializer

stu1130 avatar Jul 21 '20 23:07 stu1130

We have this now since DJL 0.18.0 https://github.com/deepjavalibrary/djl/pull/1720

siddvenk avatar Nov 10 '22 23:11 siddvenk