Skip to content

Commit faa6ea0

Browse files
committed
Add DL from scratch directory
1 parent ced4901 commit faa6ea0

File tree

5 files changed

+2601
-0
lines changed

5 files changed

+2601
-0
lines changed

DeepLeaningFromScratch/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ゼロから作るDeep Learning
2+
![書影](https://www.oreilly.co.jp/books/images/picture_large978-4-87311-758-4.jpeg)
3+
[出版社公式](https://www.oreilly.co.jp/books/9784873117584/)
4+
[正誤表](https://github.com/oreilly-japan/deep-learning-from-scratch/wiki/errata)
5+
6+
## 目次
7+
- 1章 Python入門
8+
- 2章 パーセプトロン
9+
- 3章 ニューラルネットワーク
10+
- 4章 ニューラルネットワークの学習
11+
- 5章 誤差逆伝播法
12+
- 6章 学習に関するテクニック
13+
- 7章 畳み込みニューラルネットワーク
14+
- 8章 ディープラーニング
+290
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# パーセプトロン"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 1,
13+
"metadata": {},
14+
"outputs": [
15+
{
16+
"data": {
17+
"text/plain": [
18+
"AND (generic function with 1 method)"
19+
]
20+
},
21+
"execution_count": 1,
22+
"metadata": {},
23+
"output_type": "execute_result"
24+
}
25+
],
26+
"source": [
27+
"function AND(x1, x2)\n",
28+
" w1, w2, theta = 0.5, 0.5, 0.7\n",
29+
" tmp = x1*w1 + x2*w2\n",
30+
" if tmp <= theta\n",
31+
" 0\n",
32+
" elseif tmp > theta\n",
33+
" 1\n",
34+
" end\n",
35+
"end"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": 2,
41+
"metadata": {},
42+
"outputs": [
43+
{
44+
"name": "stdout",
45+
"output_type": "stream",
46+
"text": [
47+
"0\n",
48+
"0\n",
49+
"0\n",
50+
"1\n"
51+
]
52+
}
53+
],
54+
"source": [
55+
"println(AND(0, 0))\n",
56+
"println(AND(0, 1))\n",
57+
"println(AND(1, 0))\n",
58+
"println(AND(1, 1))"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": 3,
64+
"metadata": {},
65+
"outputs": [
66+
{
67+
"name": "stdout",
68+
"output_type": "stream",
69+
"text": [
70+
"[0.0 0.5]\n",
71+
"0.5\n",
72+
"-0.19999999999999996\n"
73+
]
74+
}
75+
],
76+
"source": [
77+
"x = [0 1]\n",
78+
"w = [0.5 0.5]\n",
79+
"b = -0.7\n",
80+
"println(w.*x)\n",
81+
"println(sum(w.*x))\n",
82+
"println(sum(w.*x)+b)"
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 4,
88+
"metadata": {},
89+
"outputs": [
90+
{
91+
"data": {
92+
"text/plain": [
93+
"AND (generic function with 1 method)"
94+
]
95+
},
96+
"execution_count": 4,
97+
"metadata": {},
98+
"output_type": "execute_result"
99+
}
100+
],
101+
"source": [
102+
"function AND(x1, x2)\n",
103+
" x = [x1 x2]\n",
104+
" w = [0.5 0.5]\n",
105+
" b = -0.7\n",
106+
" tmp = sum(w.*x) + b\n",
107+
" if tmp <= 0\n",
108+
" 0\n",
109+
" else\n",
110+
" 1\n",
111+
" end\n",
112+
"end"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": 5,
118+
"metadata": {},
119+
"outputs": [
120+
{
121+
"data": {
122+
"text/plain": [
123+
"OR (generic function with 1 method)"
124+
]
125+
},
126+
"execution_count": 5,
127+
"metadata": {},
128+
"output_type": "execute_result"
129+
}
130+
],
131+
"source": [
132+
"function NAND(x1, x2)\n",
133+
" x = [x1 x2]\n",
134+
" w = [-0.5 -0.5]\n",
135+
" b = 0.7\n",
136+
" tmp = sum(w.*x) + b\n",
137+
" if tmp <= 0\n",
138+
" 0\n",
139+
" else\n",
140+
" 1\n",
141+
" end\n",
142+
"end\n",
143+
"\n",
144+
"function OR(x1, x2)\n",
145+
" x = [x1 x2]\n",
146+
" w = [0.5 0.5]\n",
147+
" b = -0.2\n",
148+
" tmp = sum(w.*x) + b\n",
149+
" if tmp <= 0\n",
150+
" 0\n",
151+
" else\n",
152+
" 1\n",
153+
" end\n",
154+
"end"
155+
]
156+
},
157+
{
158+
"cell_type": "code",
159+
"execution_count": 6,
160+
"metadata": {},
161+
"outputs": [
162+
{
163+
"name": "stdout",
164+
"output_type": "stream",
165+
"text": [
166+
"0\n",
167+
"0\n",
168+
"0\n",
169+
"1\n"
170+
]
171+
}
172+
],
173+
"source": [
174+
"println(AND(0, 0))\n",
175+
"println(AND(0, 1))\n",
176+
"println(AND(1, 0))\n",
177+
"println(AND(1, 1))"
178+
]
179+
},
180+
{
181+
"cell_type": "code",
182+
"execution_count": 7,
183+
"metadata": {},
184+
"outputs": [
185+
{
186+
"name": "stdout",
187+
"output_type": "stream",
188+
"text": [
189+
"1\n",
190+
"1\n",
191+
"1\n",
192+
"0\n"
193+
]
194+
}
195+
],
196+
"source": [
197+
"println(NAND(0, 0))\n",
198+
"println(NAND(0, 1))\n",
199+
"println(NAND(1, 0))\n",
200+
"println(NAND(1, 1))"
201+
]
202+
},
203+
{
204+
"cell_type": "code",
205+
"execution_count": 8,
206+
"metadata": {},
207+
"outputs": [
208+
{
209+
"name": "stdout",
210+
"output_type": "stream",
211+
"text": [
212+
"0\n",
213+
"1\n",
214+
"1\n",
215+
"1\n"
216+
]
217+
}
218+
],
219+
"source": [
220+
"println(OR(0, 0))\n",
221+
"println(OR(0, 1))\n",
222+
"println(OR(1, 0))\n",
223+
"println(OR(1, 1))"
224+
]
225+
},
226+
{
227+
"cell_type": "code",
228+
"execution_count": 9,
229+
"metadata": {},
230+
"outputs": [
231+
{
232+
"data": {
233+
"text/plain": [
234+
"XOR (generic function with 1 method)"
235+
]
236+
},
237+
"execution_count": 9,
238+
"metadata": {},
239+
"output_type": "execute_result"
240+
}
241+
],
242+
"source": [
243+
"function XOR(x1, x2)\n",
244+
" s1 = NAND(x1, x2)\n",
245+
" s2 = OR(x1, x2)\n",
246+
" y = AND(s1, s2)\n",
247+
" y\n",
248+
"end"
249+
]
250+
},
251+
{
252+
"cell_type": "code",
253+
"execution_count": 10,
254+
"metadata": {},
255+
"outputs": [
256+
{
257+
"name": "stdout",
258+
"output_type": "stream",
259+
"text": [
260+
"0\n",
261+
"1\n",
262+
"1\n",
263+
"0\n"
264+
]
265+
}
266+
],
267+
"source": [
268+
"println(XOR(0, 0))\n",
269+
"println(XOR(0, 1))\n",
270+
"println(XOR(1, 0))\n",
271+
"println(XOR(1, 1))"
272+
]
273+
}
274+
],
275+
"metadata": {
276+
"kernelspec": {
277+
"display_name": "Julia 0.6.0",
278+
"language": "julia",
279+
"name": "julia-0.6"
280+
},
281+
"language_info": {
282+
"file_extension": ".jl",
283+
"mimetype": "application/julia",
284+
"name": "julia",
285+
"version": "0.6.0"
286+
}
287+
},
288+
"nbformat": 4,
289+
"nbformat_minor": 2
290+
}

0 commit comments

Comments
 (0)