import numpy as np
class NeuralNetwork:
    def __init__(self, input_size, hidden_size, output_size):
        # Инициализация весов случайными значениями
        self.weights_input_hidden = np.random.rand(input_size, hidden_size)
        self.weights_hidden_output = np.random.rand(hidden_size, output_size)
        # Инициализация смещений нулями
        self.bias_hidden = np.zeros((1, hidden_size))
        self.bias_output = np.zeros((1, output_size))
        # Скорость обучения
        self.learning_rate = 0.01
    def sigmoid(self, x):
        return 1 / (1 + np.exp(-x))
    def sigmoid_derivative(self, x):
        return x * (1 - x)
    def forward(self, X):
        # Прямое распространение
        self.hidden_layer_input = np.dot(X, self.weights_input_hidden) + self.bias_hidden
        self.hidden_layer_output = self.sigmoid(self.hidden_layer_input)
        
        self.output_layer_input = np.dot(self.hidden_layer_output, self.weights_hidden_output) + self.bias_output
        self.output_layer_output = self.sigmoid(self.output_layer_input)
        return self.output_layer_output
    def back(self, X, y, output):
        # Обратное распространение ошибки
        error_output = y - output
        delta_output = error_output * self.sigmoid_derivative(output)
        error_hidden = delta_output.dot(self.weights_hidden_output.T)
        delta_hidden = error_hidden * self.sigmoid_derivative(self.hidden_layer_output)
        # Обновление весов
        self.weights_hidden_output += self.hidden_layer_output.T.dot(delta_output) * self.learning_rate
        self.weights_input_hidden += X.T.dot(delta_hidden) * self.learning_rate
        # Обновление смещений
        self.bias_output += np.sum(delta_output, axis=0, keepdims=True) * self.learning_rate
        self.bias_hidden += np.sum(delta_hidden, axis=0, keepdims=True) * self.learning_rate
    def train(self, X, y, epochs):
        for epoch in range(epochs):
            output = self.forward(X)
            self.backward(X, y, output)
            if epoch % 100 == 0:
                loss = np.mean(np.square(y - output))
                print(f"Epoch {epoch}, Loss: {loss}"
nn = NeuralNetwork(input_size=2, hidden_size=2, output_size=1)
# Обучение сети
nn.train(X, y, epochs=1000)
# Предсказание
predictions = nn.forward(X)
print("Predictions:")
print(predictions)
def __init__(self, layers):
        self.layers = layers
        self.weights = [np.random.rand(layers[i], layers[i+1]) for i in range(len(layers)-1)]
        self.biases = [np.zeros((1, layers[i+1])) for i in range(len(layers)-1)]
        self.activations = [np.zeros((1, layers[i+1])) for i in range(len(layers)-1)]
        self.derivatives = [np.zeros((1, layers[i+1])) for i in range(len(layers)-1)]
        self.learning_rate = 0.01
	def forward(self, X):
        self.activations[0] = X
        for i in range(len(self.layers)-2):
            self.activations[i+1] = self.sigmoid(np.dot(self.activations[i], self.weights[i]) + self.biases[i])
        output = self.sigmoid(np.dot(self.activations[-2], self.weights[-1]) + self.biases[-1])
        return output
    def ba(self, X, y, output):
        error_output = y - output
        self.derivatives[-1] = error_output * self.sigmoid_derivative(output)
        for i in range(len(self.layers)-3, -1, -1):
            error_hidden = self.derivatives[i+1].dot(self.weights[i+1].T)
            self.derivatives[i] = error_hidden * self.sigmoid_derivative(self.activations[i+1])
        for i in range(len(self.layers)-2, -1, -1):
            self.weights[i] += self.activations[i].T.dot(self.derivatives[i]) * self.learning_rate
            self.biases[i] += np.sum(self.derivatives[i], axis=0, keepdims=True) * self.learning_rate
    def train(self, X, y, epochs):
        for epoch in range(epochs):
            output = self.forward(X)
            self.backward(X, y, output)
            if epoch % 100 == 0:
                loss = np.mean(np.square(y - output))
                print(f"Epoch {epoch}, Loss: {loss}")


Объясни, как сюда вставить датасет, который в csv: одна строка - id, class, биты картинки где 0 белое 1 черное