search

Neural Network (MLP)

Mạng nơ-ron nhân tạo: Học ranh giới phi tuyến bằng Backpropagation.

Lớp:

Python Lab

Thực thi mô hình dựa trên trực quan hóa.

main.py
from sklearn.neural_network import MLPClassifier

# 0 điểm dữ liệu
X = [...]  # shape (0, 2)
y = [...]  # labels: 0 hoặc 1

# Khởi tạo MLP với 1 lớp ẩn 4 nơ-ron
model = MLPClassifier(
    hidden_layer_sizes=(4,),
    activation='logistic',
    learning_rate_init=0.5,
    max_iter=100
)
model.fit(X, y)

print(f"Loss: {model.loss_:.4f}")
print(f"Epochs: {model.n_iter_}")
// Kết quả (Output) sẽ xuất hiện ở đây khi nhấn Run...

hubCấu trúc MLP

MLP (Multi-Layer Perceptron) gồm 3 lớp:

Input (2)Hidden (4 nơ-ron, Sigmoid)Output (1, Sigmoid)

Mỗi nơ-ron nhận tín hiệu, nhân với trọng số (weights), cộng bias, rồi đưa qua hàm kích hoạt Sigmoid → xuất giá trị [0, 1].

replayBackpropagation

Quá trình huấn luyện lặp lại 2 bước:

  • arrow_forwardForward Pass: Truyền dữ liệu từ Input → Output, tính dự đoán.
  • arrow_backBackward Pass: Tính sai số, truyền ngược lại để điều chỉnh trọng số (Gradient Descent).

help_outlineTại sao dùng XOR?

XOR là bài toán phi tuyến kinh điển mà Perceptron đơn lớp không thể giải. Nó chứng minh sức mạnh của Neural Network nhiều lớp!

Hãy nhấn "Dữ liệu XOR" → "Huấn luyện 100 Epochs" và xem ranh giới cong dần dần hình thành.