Skip to content

Conversation

@dlalswns0211
Copy link

@dlalswns0211 dlalswns0211 commented May 14, 2025

Uploading 시그모이드_문풀.2.jpg…
import numpy as np

시그모이드 함수 및 그 미분

def sigmoid(z):
return 1 / (1 + np.exp(-z))

def sigmoid_derivative(z):
s = sigmoid(z)
return s * (1 - s)

입력값

x1 = 0.1
x2 = 0.2
y_real = 0.3
learning_rate = 0.5

가중치 초기값

w1, w2, w3, w4, w5, w6 = 0.1, 0.2, 0.3, 0.15, 0.25, 0.35

순전파

z1 = x1 * w1 + x2 * w2
h1 = sigmoid(z1)

z2 = x1 * w3 + x2 * w4
h2 = sigmoid(z2)

z3 = h1 * w5 + h2 * w6
y_pred = sigmoid(z3)

손실 함수의 출력값에 대한 오차 (Mean Squared Error 기준)

error = y_pred - y_real

출력층에서의 gradient

dL_dy = 2 * error
dy_dz3 = sigmoid_derivative(z3)
dz3_dw5 = h1

w5에 대한 gradient

dL_dw5 = dL_dy * dy_dz3 * dz3_dw5

h1에 대한 gradient

dz3_dh1 = w5
dh1_dz1 = sigmoid_derivative(z1)
dz1_dw1 = x1

w1에 대한 gradient

dL_dw1 = dL_dy * dy_dz3 * dz3_dh1 * dh1_dz1 * dz1_dw1

가중치 w1 업데이트

w1_new = w1 - learning_rate * dL_dw1

print(f"업데이트된 w1: {w1_new:.5f}")

#결과값

#업데이트된 w1: 0.09958
4th_assignment_sigmoid_이민준 - Colab.pdf

@dlalswns0211
Copy link
Author

시그모이드_문풀 2
시그모이드_문풀 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant