Image of neuron

import math


class Neuron:
    def __init__(self, num_inputs):
        self.weights = [0.0] * num_inputs
        self.bias = 0.0

    def activate(self, inputs):
        if len(inputs) != len(self.weights):
            raise ValueError("Number of inputs must match number of weights")
        weighted_sum = sum(x * w for x, w in zip(inputs, self.weights))
        activation = self._sigmoid(weighted_sum + self.bias)
        return activation

    def _sigmoid(self, x):
        return 1 / (1 + math.exp(-x))

Hi @ShyamLal6!

Your post is a little unclear. What problems are you facing and do you need help with anything? The more information you provide, the easier it is for the community to help you :upside_down_face:

4 Likes