Keras输出每一层网络大小
示例代码:
model = Model(inputs=self.inpt, outputs=self.net)
model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])
print("[INFO] Method 1...")
model.summary()
print("[INFO] Method 2...")
for i in range(len(model.layers)):
print(model.get_layer(index=i).output)
print("[INFO] Method 3...")
for layer in model.layers:
print(layer.output_shape)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/5/20
# @Author : Chen
from keras.models import Model
from keras.layers import Dense, Flatten, Input
from keras.layers import Conv2D
class Example:
def __init__(self):
self.inpt = Input(shape=(224, 224, 3))
self.net = self.build_network()
def build_network(self):
inpt = self.inpt
x = Conv2D(64, kernel_size=(3, 3), padding='same', activation='relu')(inpt)
...
x = Flatten()(x)
x = Dense(1000)(x)
return x
def get_layer(self):
model = Model(inputs=self.inpt, outputs=self.net)
model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])
print("[INFO] Method 1...")
model.summary()
print("[INFO] Method 2...")
for i in range(len(model.layers)):
print(model.get_layer(index=i).output)
print("[INFO] Method 3...")
for layer in model.layers:
print(layer.output_shape)
if __name__ == '__main__':
ex = Example()
ex.get_layer()
输出结果:
[INFO] Method 1...
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 224, 224, 3) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 224, 224, 64) 1792
_________________________________________________________________
flatten_1 (Flatten) (None, 3211264) 0
_________________________________________________________________
dense_1 (Dense) (None, 1000) -108370229
=================================================================
Total params: -1,083,700,504
Trainable params: -1,083,700,504
Non-trainable params: 0
_________________________________________________________________
[INFO] Method 2...
Tensor("input_1:0", shape=(?, 224, 224, 3), dtype=float32)
Tensor("conv2d_1/Relu:0", shape=(?, 224, 224, 64), dtype=float32)
Tensor("flatten_1/Reshape:0", shape=(?, ?), dtype=float32)
Tensor("dense_1/BiasAdd:0", shape=(?, 1000), dtype=float32)
[INFO] Method 3...
(None, 224, 224, 3)
(None, 224, 224, 64)
(None, 3211264)
(None, 1000)
Keras输出每一层网络大小的更多相关文章
- keras输出中间层结果,某一层的权重、偏置
转载:https://blog.csdn.net/hahajinbu/article/details/77982721 from keras.models import Sequential,Mode ...
- keras搭建密集连接网络/卷积网络/循环网络
输入模式与网络架构间的对应关系: 向量数据:密集连接网络(Dense层) 图像数据:二维卷积神经网络 声音数据(比如波形):一维卷积神经网络(首选)或循环神经网络 文本数据:一维卷积神经网络(首选)或 ...
- 不到 200 行代码,教你如何用 Keras 搭建生成对抗网络(GAN)【转】
本文转载自:https://www.leiphone.com/news/201703/Y5vnDSV9uIJIQzQm.html 生成对抗网络(Generative Adversarial Netwo ...
- 用keras作CNN卷积网络书本分类(书本、非书本)
本文介绍如何使用keras作图片分类(2分类与多分类,其实就一个参数的区别...呵呵) 先来看看解决的问题:从一堆图片中分出是不是书本,也就是最终给图片标签上:“书本“.“非书本”,简单吧. 先来看看 ...
- keras的网络结构与网络配置
摘自: https://www.cnblogs.com/Anita9002/p/8136357.html Keras的网络配置
- Qt编写调试日志输出类带网络转发(开源)
用qt开发商业程序已经九年了,陆陆续续开发过至少几十个程序,除了一些算不算项目的小工具外,大部分的程序都需要有个日志的输出功能,希望可以将程序的运行状态存储到文本文件或者数据库或者做其他处理等,qt对 ...
- 解决Latex输出PDF纸张自适应大小及中文无法显示问题
遗留的问题 之前我们进行了基于texlive定制chemfig化学式转换Python服务镜像,虽然完成pdf的输出服务改造,但是输出效果并不是太好,如下图: 这个图有两个比较严重问题 不支持中文 空白 ...
- js Date()获取时间,格式化输出,时间比较大小
1.获取时间并且格式化输出 new Date().toLocaleString('cn',{hour12:false}) //2018/12/6 17:57:15 new Date().toLocal ...
- Tomcat输出catalina.out的大小控制
资源URL:http://download.csdn.net/detail/attagain/7771065 Tomcat默认生成的日志文件catalina.out,随着时间的推移,逐渐增大,可能达到 ...
随机推荐
- java.lang.UnsupportedClassVersionError: org/openqa/selenium/WebDriver : Unsupported major.minor version 51.0
周一上班,正常打开myeclipse,随便写了一个main方法执行.发现报错了... 问题提示如下: java.lang.UnsupportedClassVersionError: org/openq ...
- Gemini.Workflow 双子工作流入门教程二:定义流程:流程节点介绍
简介: Gemini.Workflow 双子工作流,是一套功能强大,使用简单的工作流,简称双子流,目前配套集成在Aries框架中. 下面介绍本篇教程:流程定义:流程节点属性. 流程节点: 左侧是节点工 ...
- java和js互调 拨打电话
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 【Leetcode-easy】ZigZag Conversion
思路1:String[numRow]行字符串数组.读取原始字符串每一个字符,设置行变量 nrow和行标志位flag(向下一行为1或向上一行为-1).将该字符连接到数组中对应的行字符串,同时nrow+= ...
- STS、Eclipse报java.lang.OutOfMemoryError: PermGen space 内存溢出
我使用的工具是STS, Eclipse同理: 打开如下界面: 左则选择项目启动使用的Tomcat-->在右侧面板Tab项中选择" Arguments":在VM argumen ...
- HDU4825 Xor Sum —— Trie树
题目链接:https://vjudge.net/problem/HDU-4825 Xor Sum Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- POJ1185 炮兵阵地 —— 状压DP
题目链接:http://poj.org/problem?id=1185 炮兵阵地 Time Limit: 2000MS Memory Limit: 65536K Total Submissions ...
- 【LeetCode】求众数
给定一个大小为 n 的数组,找到其中的众数.众数是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素. 你可以假设数组是非空的,并且给定的数组总是存在众数. class Solution(object): ...
- Spring当中的名称装配和类型装配有什么区别?
6 人赞同了该回答 Spring auto-wire的 五种方式:1:no 默认的方式是不进行自动装配,通过手工设置ref 属性来进行装配bean2:byName 通过参数名 自动装配,如果一个bea ...
- ansible mysql模块的使用今年
摘自: https://www.ibm.com/developerworks/cn/linux/1502_lih_ansible/