怎么查看下载的.npy模型里面的参数

根据Kevin 训练VGG教程而来


假设我们这里已经有了一个VGG16层的参数原始文件,想要打开来看一下参数设置,使用以下函数就行了,涉及到的库自行补充

测试加载进来的参数
def test_load():
    data_path = './/VGG-pretrain//vgg16.npy'  # 文件保存路径
    # 注意这个文件要到网上自行下载
    data_dict = np.load(data_path, encoding='latin1').item()
    keys = sorted(data_dict.keys())
    for key in keys:
        weights = data_dict[key][0]
        biases = data_dict[key][1]
        print('\n')
        print(key)
        print('weights shape: ', weights.shape)
        print('biases shape: ', biases.shape)

结果展示:

conv1_1

weights shape:  (3, 3, 3, 64)
biases shape:  (64,)




conv1_2
weights shape:  (3, 3, 64, 64)
biases shape:  (64,)




conv2_1
weights shape:  (3, 3, 64, 128)
biases shape:  (128,)




conv2_2
weights shape:  (3, 3, 128, 128)
biases shape:  (128,)




conv3_1
weights shape:  (3, 3, 128, 256)
biases shape:  (256,)




conv3_2
weights shape:  (3, 3, 256, 256)
biases shape:  (256,)




conv3_3
weights shape:  (3, 3, 256, 256)
biases shape:  (256,)




conv4_1
weights shape:  (3, 3, 256, 512)
biases shape:  (512,)




conv4_2
weights shape:  (3, 3, 512, 512)
biases shape:  (512,)




conv4_3
weights shape:  (3, 3, 512, 512)
biases shape:  (512,)




conv5_1
weights shape:  (3, 3, 512, 512)
biases shape:  (512,)




conv5_2
weights shape:  (3, 3, 512, 512)
biases shape:  (512,)




conv5_3
weights shape:  (3, 3, 512, 512)
biases shape:  (512,)




fc6
weights shape:  (25088, 4096)
biases shape:  (4096,)




fc7
weights shape:  (4096, 4096)
biases shape:  (4096,)




fc8
weights shape:  (4096, 1000)
biases shape:  (1000,)

你可能感兴趣的:(tensorflow)