import mxnet as mx
import pdb
def load_checkpoint():
"""
Load model checkpoint from file.
:param prefix: Prefix of model name.
:param epoch: Epoch number of model we would like to load.
:return: (arg_params, aux_params)
arg_params : dict of str to NDArray
Model parameter, dict of name to NDArray of net's weights.
aux_params : dict of str to NDArray
Model parameter, dict of name to NDArray of net's auxiliary states.
"""
save_dict = mx.nd.load('model-0000.params')
arg_params = {}
aux_params = {}
for k, v in save_dict.items():
tp, name = k.split(':', 1)
if tp == 'arg':
arg_params[name] = v
if tp == 'aux':
aux_params[name] = v
return arg_params, aux_params def convert_context(params, ctx):
"""
:param params: dict of str to NDArray
:param ctx: the context to convert to
:return: dict of str of NDArray with context ctx
"""
new_params = dict()
for k, v in params.items():
new_params[k] = v.as_in_context(ctx)
#print new_params[0]
return new_params def load_param(convert=False, ctx=None):
"""
wrapper for load checkpoint
:param prefix: Prefix of model name.
:param epoch: Epoch number of model we would like to load.
:param convert: reference model should be converted to GPU NDArray first
:param ctx: if convert then ctx must be designated.
:return: (arg_params, aux_params)
"""
arg_params, aux_params = load_checkpoint()
if convert:
if ctx is None:
ctx = mx.cpu()
arg_params = convert_context(arg_params, ctx)
aux_params = convert_context(aux_params, ctx)
return arg_params, aux_params if __name__=='__main__':
result = load_param();
#pdb.set_trace()
print 'result is'
#print result
for dic in result:
for key in dic:
print(key,dic[key].shape)
# print 'one of results is:'
# print result[0]['fc2_weight'].asnumpy()

python showmxmodel.py 2>&1 | tee log.txt
result is
('stage3_unit2_bn1_beta', (256L,))
('stage3_unit2_bn3_beta', (256L,))
('stage3_unit11_bn1_gamma', (256L,))
('stage3_unit5_bn3_gamma', (256L,))
('stage3_unit3_conv1_weight', (256L, 256L, 3L, 3L))
('stage2_unit1_bn3_gamma', (128L,))
('stage3_unit4_conv1_weight', (256L, 256L, 3L, 3L))
('stage3_unit12_bn3_beta', (256L,))
('stage2_unit2_bn3_beta', (128L,))
('conv0_weight', (64L, 3L, 3L, 3L))
('stage3_unit11_relu1_gamma', (256L,))
('stage4_unit1_conv1sc_weight', (512L, 256L, 1L, 1L))
('stage3_unit1_conv1sc_weight', (256L, 128L, 1L, 1L))
('bn1_beta', (512L,))
('stage1_unit2_bn2_beta', (64L,))
('stage3_unit2_conv2_weight', (256L, 256L, 3L, 3L))
('stage1_unit2_conv1_weight', (64L, 64L, 3L, 3L))
('stage3_unit14_bn2_beta', (256L,))
('stage4_unit2_bn3_beta', (512L,))
('stage3_unit8_bn1_gamma', (256L,))
('stage3_unit7_bn1_gamma', (256L,))
('stage2_unit3_bn1_beta', (128L,))
('stage2_unit4_conv1_weight', (128L, 128L, 3L, 3L))
('stage3_unit2_bn2_gamma', (256L,))
('stage1_unit1_conv1_weight', (64L, 64L, 3L, 3L))
('stage3_unit9_conv2_weight', (256L, 256L, 3L, 3L))
('stage3_unit13_conv1_weight', (256L, 256L, 3L, 3L))
('stage3_unit1_relu1_gamma', (256L,))
('stage4_unit1_bn3_beta', (512L,))
('stage2_unit1_bn2_beta', (128L,))
('stage3_unit14_conv1_weight', (256L, 256L, 3L, 3L))
('stage3_unit8_bn1_beta', (256L,))
('stage3_unit11_conv1_weight', (256L, 256L, 3L, 3L))
('stage1_unit1_bn3_gamma', (64L,))
('stage2_unit2_conv2_weight', (128L, 128L, 3L, 3L))
('stage4_unit2_bn1_gamma', (512L,))
('stage3_unit3_bn1_gamma', (256L,))
('stage1_unit3_bn2_gamma', (64L,))
('stage1_unit3_bn3_gamma', (64L,))
('stage4_unit2_relu1_gamma', (512L,))
('stage3_unit10_conv2_weight', (256L, 256L, 3L, 3L))
('stage3_unit12_conv1_weight', (256L, 256L, 3L, 3L))
('stage3_unit2_relu1_gamma', (256L,))
('stage3_unit10_bn2_beta', (256L,))
('stage2_unit3_bn3_gamma', (128L,))
('stage2_unit3_bn2_beta', (128L,))
('stage3_unit8_bn3_beta', (256L,))
('fc1_gamma', (512L,))
('stage3_unit14_bn3_gamma', (256L,))
('stage3_unit9_bn3_gamma', (256L,))
('stage2_unit3_bn3_beta', (128L,))
('stage3_unit1_sc_gamma', (256L,))
('stage3_unit7_bn1_beta', (256L,))
('stage1_unit2_bn3_beta', (64L,))
('stage3_unit14_relu1_gamma', (256L,))
('stage3_unit13_bn2_beta', (256L,))
('stage2_unit1_conv1sc_weight', (128L, 64L, 1L, 1L))
('bn0_beta', (64L,))
('stage3_unit12_bn1_gamma', (256L,))
('stage2_unit1_sc_gamma', (128L,))
('relu0_gamma', (64L,))
('stage2_unit2_bn2_gamma', (128L,))
('stage3_unit4_relu1_gamma', (256L,))

Mxnet 查看模型params的网络结构的更多相关文章

  1. tensorflow 查看模型输入输出saved_model_cli show --dir ./xxxx --all

    saved_model_cli show --dir ./xxxxxxxx --all 可以查看模型的输入输出,比如使用tensorflow export_model_inference.py 输出的 ...

  2. 【tensorflow-v2.0】如何查看模型的输入输出流的属性

    操作过程: 1. 查看mobilenet的variables loaded = tf.saved_model.load('mobilenet') print('MobileNet has {} tra ...

  3. Tensorflow学习教程------模型参数和网络结构保存且载入,输入一张手写数字图片判断是几

    首先是模型参数和网络结构的保存 #coding:utf-8 import tensorflow as tf from tensorflow.examples.tutorials.mnist impor ...

  4. 在3D Max中查看模型引用的贴图

    需求 假如在Max中有一个模型,想查看贴图 操作步骤 1.右上角点击 2.在弹出材质编辑器中 点击吸管 3.把吸管点击在角色模型上,然后点击M 4.点击查看图像 5.就能查看到模型使用的贴图

  5. pytorch查看模型weight与grad

    在用pdb debug的时候,有时候需要看一下特定layer的权重以及相应的梯度信息,如何查看呢? 1. 首先把你的模型打印出来,像这样 2. 然后观察到model下面有module的key,modu ...

  6. ROS学习笔记十一:创建URDF 文件并在RVIZ中查看模型

    Unified Robot Description Format,简称为URDF(标准化机器人描述格式),是一种用于描述机器人及其部分结构.关节.自由度等的XML格式文件. 一.创建第一个URDF文件 ...

  7. 【新人赛】阿里云恶意程序检测 -- 实践记录10.13 - Google Colab连接 / 数据简单查看 / 模型训练

    1. 比赛介绍 比赛地址:阿里云恶意程序检测新人赛 这个比赛和已结束的第三届阿里云安全算法挑战赛赛题类似,是一个开放的长期赛. 2. 前期准备 因为训练数据量比较大,本地CPU跑不起来,所以决定用Go ...

  8. mxnet 查看 Sym shape

    import mxnet as mximport numpy as npimport randomimport mxnet as mximport sysdata_shape = {'data':(6 ...

  9. keras API的使用,神经网络层,优化器,损失函数,查看模型层数,compile和fit训练

    layers介绍 Flatten和Dense介绍 优化器 损失函数 compile用法 第二个是onehot编码 模型训练 model.fit  两种创建模型的方法 from tensorflow.p ...

随机推荐

  1. [svc]linux正则及grep常用手法

    正则测试 可以用sublime等工具快速的检测正则是否合适 china : 匹配此行中任意位置有china字符的行 ^china : 匹配此以china开关的行 china$ : 匹配以china结尾 ...

  2. [na]数据链路层&网络层协议小结截图版

    ip层:分组选路 tcp:端到端的通信 中间系统没必要有应用程序,分组选路即可 应用程序中隐藏所有的物理细节. 语音肯定用udp linux主版本 次版本号 修订号 次版本为偶数说明是稳定版.奇数是开 ...

  3. angular内置过滤器-filter

    这篇文章来讲解一下angular内置的filter过滤器. 没错,这个过滤器的名字,就叫'filter',虽然自定义过滤器也是使用module.filter()...但是不要混淆了,这个filter就 ...

  4. 微信小程序启动过程分析

    1.微信客户端在打开小程序之前,会把整个小程序的代码包下载到本地. 2.紧接着通过 app.json 的 pages 字段就可以知道你当前小程序的所有页面路径: { "pages" ...

  5. (原创)用c++11打造类似于python的range

    python中的range函数表示一个连续的有序序列,range使用起来很方便,因为在定义时就隐含了初始化过程,因为只需要给begin()和end()或者仅仅一个end(),就能表示一个连续的序列.还 ...

  6. 白话 Ruby 与 DSL 以及在 iOS 开发中的运用

    每日一篇优秀博文 2017年10月7日 周六 白话 Ruby 与 DSL 以及在 iOS 开发中的运用 阅读本文不需要预先掌握 Ruby 与 DSL 相关的知识 何为 DSL DSL(Domain S ...

  7. vim复制,粘贴,删除,撤销,替换,光标移动等用法

    我接触linux的时候,用的是nano这个文本编辑器,个人觉得他的最大优点就是方便,快速.打开文件,修改文件,到退出都十分的快速,简单.这一点上比vi,vim要强,但是nano不能显示彩色字,不能进行 ...

  8. Python实现二叉树的左中右序遍历

    #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/3/18 12:31 # @Author : baoshan # @Site ...

  9. Python通过ssh连接服务器并执行命令

    [本文出自天外归云的博客园] 脚本示例如下: # coding:utf-8 import time,paramiko,re,StringIO def exec_shell(command): ''' ...

  10. One-hot 编码/TF-IDF 值来提取特征,LAD/梯度下降法(Gradient Descent),Sigmoid

    1. 多值无序类数据的特征提取: 多值无序类问题(One-hot 编码)把“耐克”编码为[0,1,0],其中“1”代表了“耐克”的中 间位置,而且是唯一标识.同理我们可以把“中国”标识为[1,0],把 ...