Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f85f1d7

Browse files
committed
and example Jupyter notebook
1 parent 8fc57fd commit f85f1d7

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed

‎example.ipynb

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {
7+
"collapsed": false
8+
},
9+
"outputs": [
10+
{
11+
"name": "stderr",
12+
"output_type": "stream",
13+
"text": [
14+
"Using Theano backend.\n"
15+
]
16+
}
17+
],
18+
"source": [
19+
"from keras.models import Sequential\n",
20+
"from keras import layers as l\n",
21+
"from keras.applications.vgg16 import VGG16\n",
22+
"from keras_sequential_ascii import sequential_model_to_ascii_printout"
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"execution_count": 3,
28+
"metadata": {
29+
"collapsed": false
30+
},
31+
"outputs": [],
32+
"source": [
33+
"# this model makes no sense - just a visualization of this library\n",
34+
"model = Sequential()\n",
35+
"model.add(l.BatchNormalization(input_shape=(3, 32, 32)))\n",
36+
"model.add(l.Convolution2D(16, 3, 3, activation='relu'))\n",
37+
"model.add(l.Convolution2D(16, 3, 3, activation='relu'))\n",
38+
"model.add(l.MaxPooling2D((2, 2)))\n",
39+
"model.add(l.Convolution2D(16, 1, 1, activation='tanh'))\n",
40+
"model.add(l.Flatten())\n",
41+
"model.add(l.Dense(16))\n",
42+
"model.add(l.Dropout(0.5))\n",
43+
"model.add(l.Dense(3, activation='softmax'))\n",
44+
"\n"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": 4,
50+
"metadata": {
51+
"collapsed": false
52+
},
53+
"outputs": [
54+
{
55+
"name": "stdout",
56+
"output_type": "stream",
57+
"text": [
58+
" OPERATION DATA DIMENSIONS WEIGHTS(N) WEIGHTS(%)\n",
59+
"\n",
60+
" Input ##### 3 32 32\n",
61+
" BatchNormalization μ|σ ------------------- 64 0.1%\n",
62+
" ##### 3 32 32\n",
63+
" Convolution2D \\|/ ------------------- 448 0.8%\n",
64+
" relu ##### 16 30 30\n",
65+
" Convolution2D \\|/ ------------------- 2320 4.4%\n",
66+
" relu ##### 16 28 28\n",
67+
" MaxPooling2D YYYYY ------------------- 0 0.0%\n",
68+
" ##### 16 14 14\n",
69+
" Convolution2D \\|/ ------------------- 272 0.5%\n",
70+
" tanh ##### 16 14 14\n",
71+
" Flatten ||||| ------------------- 0 0.0%\n",
72+
" ##### 3136\n",
73+
" Dense XXXXX ------------------- 50192 94.1%\n",
74+
" ##### 16\n",
75+
" Dropout | || ------------------- 0 0.0%\n",
76+
" ##### 16\n",
77+
" Dense XXXXX ------------------- 34 0.1%\n",
78+
" ##### 2\n"
79+
]
80+
}
81+
],
82+
"source": []
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": 5,
87+
"metadata": {
88+
"collapsed": false
89+
},
90+
"outputs": [
91+
{
92+
"name": "stdout",
93+
"output_type": "stream",
94+
"text": [
95+
" OPERATION DATA DIMENSIONS WEIGHTS(N) WEIGHTS(%)\n",
96+
"\n",
97+
" Input ##### 3 224 224\n",
98+
" InputLayer ????? ------------------- 0 0.0%\n",
99+
" ##### 3 224 224\n",
100+
" Convolution2D \\|/ ------------------- 1792 0.0%\n",
101+
" relu ##### 64 224 224\n",
102+
" Convolution2D \\|/ ------------------- 36928 0.0%\n",
103+
" relu ##### 64 224 224\n",
104+
" MaxPooling2D YYYYY ------------------- 0 0.0%\n",
105+
" ##### 64 112 112\n",
106+
" Convolution2D \\|/ ------------------- 73856 0.1%\n",
107+
" relu ##### 128 112 112\n",
108+
" Convolution2D \\|/ ------------------- 147584 0.1%\n",
109+
" relu ##### 128 112 112\n",
110+
" MaxPooling2D YYYYY ------------------- 0 0.0%\n",
111+
" ##### 128 56 56\n",
112+
" Convolution2D \\|/ ------------------- 295168 0.2%\n",
113+
" relu ##### 256 56 56\n",
114+
" Convolution2D \\|/ ------------------- 590080 0.4%\n",
115+
" relu ##### 256 56 56\n",
116+
" Convolution2D \\|/ ------------------- 590080 0.4%\n",
117+
" relu ##### 256 56 56\n",
118+
" MaxPooling2D YYYYY ------------------- 0 0.0%\n",
119+
" ##### 256 28 28\n",
120+
" Convolution2D \\|/ ------------------- 1180160 0.9%\n",
121+
" relu ##### 512 28 28\n",
122+
" Convolution2D \\|/ ------------------- 2359808 1.7%\n",
123+
" relu ##### 512 28 28\n",
124+
" Convolution2D \\|/ ------------------- 2359808 1.7%\n",
125+
" relu ##### 512 28 28\n",
126+
" MaxPooling2D YYYYY ------------------- 0 0.0%\n",
127+
" ##### 512 14 14\n",
128+
" Convolution2D \\|/ ------------------- 2359808 1.7%\n",
129+
" relu ##### 512 14 14\n",
130+
" Convolution2D \\|/ ------------------- 2359808 1.7%\n",
131+
" relu ##### 512 14 14\n",
132+
" Convolution2D \\|/ ------------------- 2359808 1.7%\n",
133+
" relu ##### 512 14 14\n",
134+
" MaxPooling2D YYYYY ------------------- 0 0.0%\n",
135+
" ##### 512 7 7\n",
136+
" Flatten ||||| ------------------- 0 0.0%\n",
137+
" ##### 25088\n",
138+
" Dense XXXXX ------------------- 102764544 74.3%\n",
139+
" relu ##### 4096\n",
140+
" Dense XXXXX ------------------- 16781312 12.1%\n",
141+
" relu ##### 4096\n",
142+
" Dense XXXXX ------------------- 4097000 3.0%\n",
143+
" softmax ##### 1000\n"
144+
]
145+
}
146+
],
147+
"source": [
148+
"vgg16 = VGG16(weights=None)\n",
149+
"sequential_model_to_ascii_printout(vgg16)"
150+
]
151+
},
152+
{
153+
"cell_type": "code",
154+
"execution_count": 6,
155+
"metadata": {
156+
"collapsed": false
157+
},
158+
"outputs": [
159+
{
160+
"ename": "NameError",
161+
"evalue": "name 'z' is not defined",
162+
"output_type": "error",
163+
"traceback": [
164+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
165+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
166+
"\u001b[0;32m<ipython-input-6-d46262532051>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mz\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
167+
"\u001b[0;31mNameError\u001b[0m: name 'z' is not defined"
168+
]
169+
}
170+
],
171+
"source": [
172+
"len(z)"
173+
]
174+
},
175+
{
176+
"cell_type": "code",
177+
"execution_count": null,
178+
"metadata": {
179+
"collapsed": true
180+
},
181+
"outputs": [],
182+
"source": []
183+
}
184+
],
185+
"metadata": {
186+
"anaconda-cloud": {},
187+
"kernelspec": {
188+
"display_name": "Python [default]",
189+
"language": "python",
190+
"name": "python3"
191+
},
192+
"language_info": {
193+
"codemirror_mode": {
194+
"name": "ipython",
195+
"version": 3
196+
},
197+
"file_extension": ".py",
198+
"mimetype": "text/x-python",
199+
"name": "python",
200+
"nbconvert_exporter": "python",
201+
"pygments_lexer": "ipython3",
202+
"version": "3.5.2"
203+
}
204+
},
205+
"nbformat": 4,
206+
"nbformat_minor": 1
207+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /