Python 1
Python 1
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def sigmoid_derivative(x):
return x * (1 - x)
# Perceptron multicouche
class MLP:
self.hidden_output = sigmoid(self.hidden_input)
self.final_output = sigmoid(self.final_input)
return self.final_output
output_error = y - self.final_output
for _ in range(epochs):
self.forward(X)
self.backward(X, y, learning_rate)
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]]) # Entrées (porte logique XOR)
# Test du modèle
predictions = model.forward(X)
print(f"Prédictions :\n{predictions}")