<jupyter_start><jupyter_text>課程目標:        了解反向傳播的原理與在神經網路推倒過程中的作用  範例重點:    (1)自定義神經網路架構        (2) 初始值設定        (3) 使用範例<jupyter_code>#定義並建立一神經網路
class mul_layer():
    def _ini_(self):
        self.x = None
        self.y = None
    def forward(self, x, y):
        self.x = x
        self.y = y
        out = x*y
        return out
    def backward(self, dout):
        dx = dout * self.y
        dy = dout * self.x
        return dx, dy
# 初始值設定
n_X = 2
price_Y = 100
b_TAX = 1.1

# 指定Build _Network組合
mul_fruit_layer = mul_layer()
mul_tax_layer = mul_layer()<jupyter_output><empty_output><jupyter_text>以購買水果為例:        付費總價格是根據水果價格, 稅金變動而受影響        水果價格是根據購買數量與單品價格而變動        可以利用每一個cell (cell - 1: 水果價格; cell - 2: 付費總價格), 推導微分的結果<jupyter_code>#forward 
fruit_price = mul_fruit_layer.forward(price_Y, n_X)
total_price = mul_tax_layer.forward(fruit_price, b_TAX)

#backward 
dtotal_price = 1 #this is linear function, which y=x, dy/dx=1
d_fruit_price, d_b_TAX = mul_tax_layer.backward(dtotal_price)
d_price_Y, d_n_X =  mul_tax_layer.backward(d_fruit_price)
#result
print("fruit price: %i"%fruit_price)
print("針對所有水果價格微分, 得到 TAX: %2f" %d_fruit_price)<jupyter_output>fruit price: 200
針對所有水果價格微分, 得到 TAX: 1.100000
{'fraction_non_alphanumeric': 0.10561056105610561, 'fraction_numerical': 0.019801980198019802, 'mean_word_length': 3.427007299270073, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '111835', 'license': 'MIT', 'n_tokens_mistral': 664, 'n_tokens_neox': 665, 'n_words': 101, 'path': 'homeworks/D075/Day75-Back_Propagation.ipynb', 'repo_name': 'peteryuX/100Day-ML-Marathon', 'size': '1212'}