Rectified Linear Activation Function
อย่างที่ Dan อธิบายไปในวิดีโอ "ฟังก์ชัน activation" คือฟังก์ชันที่ถูกนำไปใช้กับแต่ละโหนด โดยแปลงค่า input ของโหนดนั้นให้เป็น output
ฟังก์ชัน rectified linear activation (เรียกว่า ReLU) ได้รับการพิสูจน์แล้วว่าช่วยให้โครงข่ายประสาทเทียมมีประสิทธิภาพสูงมาก ฟังก์ชันนี้รับตัวเลขเพียงค่าเดียวเป็น input โดยคืนค่า 0 หาก input เป็นค่าลบ และคืนค่า input นั้นเองหากเป็นค่าบวก
ตัวอย่างเช่น:
relu(3) = 3
relu(-3) = 0
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Introduction to Deep Learning in Python
คำแนะนำการฝึกหัด
- เติมนิยามของฟังก์ชัน
relu()ให้สมบูรณ์:- ใช้ฟังก์ชัน
max()เพื่อคำนวณค่า output ของrelu()
- ใช้ฟังก์ชัน
- นำฟังก์ชัน
relu()ไปใช้กับnode_0_inputเพื่อคำนวณnode_0_output - นำฟังก์ชัน
relu()ไปใช้กับnode_1_inputเพื่อคำนวณnode_1_output
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
def relu(input):
'''Define your relu activation function here'''
# Calculate the value for the output of the relu function: output
output = max(____, ____)
# Return the value just calculated
return(output)
# Calculate node 0 value: node_0_output
node_0_input = (input_data * weights['node_0']).sum()
node_0_output = ____
# Calculate node 1 value: node_1_output
node_1_input = (input_data * weights['node_1']).sum()
node_1_output = ____
# Put node values into array: hidden_layer_outputs
hidden_layer_outputs = np.array([node_0_output, node_1_output])
# Calculate model output (do not apply relu)
model_output = (hidden_layer_outputs * weights['output']).sum()
# Print model output
print(model_output)