| μΌ | μ | ν | μ | λͺ© | κΈ | ν |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
- νμ΄μ¬
- latent factor
- SQL
- μκ³ λ¦¬μ¦
- sklearn
- μ¬μ΄ν·λ°
- 무결μ±
- ALTERTABLE
- CREATETABLE
- TDD
- ν
- DROPTABLE
- ν΄λ¦°μ½λ
- μ£Όμ±λΆ μ°ΎκΈ°
- Hyperlink Graphs
- 무결μ±μ μ§
- Python
- μΈλλ³κ°λΉμ§μ»¬λ ν°
- Key μ’ λ₯
- SQLDDL
- λ¬Έμμ΄
- λ°±μ€
- 컨ν μ΄λκ°μ²΄
- 무결μ±μ μ§λ©μ»€λμ¦
- latent factor model
- ν€ μ’ λ₯
- μ μ¬μμλͺ¨λΈ
- knn_classify
- λΆκ½λ°μ΄ν°μ
- RENAMETABLE
- Today
- Total
DonHurry
step13. κ°λ³ κΈΈμ΄ μΈμ(μμ ν νΈ) λ³Έλ¬Έ
π’ λ³Έ ν¬μ€ν μ λ°λ°λ₯λΆν° μμνλ λ₯λ¬λ3μ κΈ°λ°μΌλ‘ μμ±νμμ΅λλ€. λ°°μ΄ λ΄μ©μ κΈ°λ‘νκ³ , κ°μΈμ μΈ κ³΅λΆλ₯Ό μν΄ μμ±νλ ν¬μ€ν μ λλ€. μμΈν λ΄μ©μ κ΅μ¬ ꡬ맀λ₯Ό κ°λ ₯ μΆμ²λ립λλ€.

μ΄μ λ¨κ³κΉμ§λ ν¨μκ° μ¬λ¬ κ°μ λ³μλ₯Ό μ λ ₯λ°κ³ λ°νν μ μλλ‘ νκ³ , μμ νμκΉμ§ λ°μνμ΅λλ€. μ΄λ²μλ μμ νμ λλ€.
μλ λ§μ κ³μ° κ·Έλνμμ μμ νλ μ λ ₯μ΄ 1κ°, μΆλ ₯μ΄ 2κ°μ λλ€. μ΄λ $y=x0+x1$μμ $x0$κ³Ό $x1$ κ°κ°μ λν΄ νΈλ―ΈλΆμ μ§ννλ©΄ κ°κ° 1, 1μ΄ λμ΅λλ€. λ§μ μ μμ νλ μΆλ ₯ μͺ½μμ μ ν΄μ§λ λ―ΈλΆκ°μ 1μ κ³±ν κ°μ΄ μ λ ₯ λ³μ (x0, x1)μ λ―ΈλΆμ λλ€. μ¦, μλ₯μμ νλ¬μ€λ λ―ΈλΆκ°μ κ·Έλλ‘ νλ €λ³΄λ΄λ κ²μ΄ λ§μ μ μμ νμ λλ€.

μ λ΄μ©λ€μ λ°μνμ¬ Add ν΄λμ€λ₯Ό λ€μκ³Ό κ°μ΄ ꡬνν μ μμ΅λλ€. μλμ μ½λκ° λμνλ €λ©΄ Variable ν΄λμ€λ μμ νμ¬μΌ ν©λλ€.
class Add(Function):
def forward(self, x0, x1):
y = x0 + x1
return y
def backward(self, gy):
return gy, gy
κΈ°μ‘΄ μ½λμμ μ΄ λ€ κ΅°λ°λ₯Ό μμ ν΄μΌ ν©λλ€. 1λ²μμ μΆλ ₯ λ³μμΈ outputsμ λ΄κ²¨ μλ λ―ΈλΆκ°λ€μ 리μ€νΈμ μ μ₯ν©λλ€. 2λ²μμλ μμ νλ₯Ό νΈμΆν©λλ€. 3λ²μμλ gxsκ° ννμ΄ μλ κ²½μ°λ₯Ό κ³ λ €ν΄μ€λλ€. λ§μ§λ§μΌλ‘ 4λ²μμλ μμ νλ‘ μ νλλ λ―ΈλΆκ°μ Variable μΈμ€ν΄μ€ λ³μμΈ gradμ μ μ₯ν©λλ€.
class Variable:
...
def backward(self):
if self.grad is None:
self.grad = np.ones_like(self.data)
funcs = [self.creator]
while funcs:
f = funcs.pop()
gys = [output.grad for output in f.outputs] # 1
gxs = f.backward(*gys) # 2
if not isinstance(gxs, tuple): # 3
gxs = (gxs, )
for x, gx in zip(f.inputs, gxs): # 4
x.grad = gx
if x.creator is not None:
funcs.append(x.creator)
κ°μ λ ν΄λμ€λ₯Ό λ°νμΌλ‘ Square ν΄λμ€λ μμ ν΄λ³΄κ² μ΅λλ€. self.inputs.data λΆλΆλ§ λ³κ²½ν΄μ£Όλ©΄ λ©λλ€.
class Square(Function):
def forward(self, x):
y = x ** 2
return y
def backward(self, gy):
x = self.inputs[0].data # μμ
gx = 2 * x * gy
return gx
λ§μ§λ§μΌλ‘ add ν¨μμ square ν¨μλ₯Ό μ¬μ©ν΄λ΄ μλ€. $z=x^2+y^2$λ₯Ό κ³μ°νλ μ½λμ λλ€. μ΄μμΌλ‘ 볡μ μ μΆλ ₯μ λμνμ¬ μλ λ―ΈλΆ κ΅¬μ‘°λ₯Ό μμ±νμ΅λλ€. λ€λ§, μ§κΈμ DeZeroλ λͺ κ°μ§ λ¬Έμ κ° μ¨μ΄ μμ΄, λ€μ λ¨κ³μμ μ΄ λ¬Έμ λ€μ ν΄κ²°ν΄λ³΄κ² μ΅λλ€.
x = Variable(np.array(2.0))
y = Variable(np.array(3.0))
z = add(square(x), square(y))
z.backward()
print(z.data) # 13.0
print(x.grad) # 4.0
print(y.grad) # 6.0'DeZero > π»μ 2κ³ μ§' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
| step16. 볡μ‘ν κ³μ° κ·Έλν(ꡬν νΈ) (0) | 2023.01.17 |
|---|---|
| step15. 볡μ‘ν κ³μ° κ·Έλν(μ΄λ‘ νΈ) (0) | 2023.01.16 |
| step14. κ°μ λ³μ λ°λ³΅ μ¬μ© (0) | 2023.01.15 |
| step12. κ°λ³ κΈΈμ΄ μΈμ(κ°μ νΈ) (0) | 2023.01.13 |
| step11. κ°λ³ κΈΈμ΄ μΈμ(μμ ν νΈ) (0) | 2023.01.12 |