# lecture_01

# Neuron with 3 inputs¶

In [4]:

    inputs = [1, 2, 3]
    weights = [0.2, 0.8, -0.5]
    bias = 2

    output = (inputs[0]*weights[0] + inputs[1]*weights[1] + inputs[2]*weights[2] + bias)

    print(f"Output: {output}")

    Output: 2.3

# Neuron with 4 inputs¶

In [5]:

    inputs = [1.0, 2.0, 3.0, 2.5]
    weights = [0.2, 0.8, -0.5, 1.0]
    bias = 2

    output = (inputs[0]*weights[0] + inputs[1]*weights[1] + inputs[2]*weights[2] + inputs[3]*weights[3] + bias)

    print(output)

    Output: 4.8

# Layer of 3 neurons with 4 inputs¶

In [1]:

    num_neurons = 3
    num_inputs = 4
    inputs = [1.0, 2.0, 3.0, 2.5]
    weights = [[0.2, 0.8, -0.5, 1.0],
               [0.5, -0.91, 0.26, -0.5],
               [-0.26, -0.27, 0.17, 0.87]]
    biases = [2, 3, 0.5]

    outputs = []
    for i in range(num_neurons):
        output = 0
        for j in range(num_inputs):
            output += inputs[j]*weights[i][j]
        output += biases[i]
        outputs.append(output)

    print(outputs)

    [4.8, 1.21, 2.385]

# Layer of 3 neurons with 4 inputs¶

In [2]:

    num_neurons = 3
    num_inputs = 4
    inputs = [1.0, 2.0, 3.0, 2.5]
    weights = [[0.2, 0.8, -0.5, 1.0],
               [0.5, -0.91, 0.26, -0.5],
               [-0.26, -0.27, 0.17, 0.87]]
    biases = [2, 3, 0.5]

    outputs = []
    for neuron_weights, neuron_bias in zip(weights, biases):
        neuron_output = 0
        for input, weight in zip(inputs, neuron_weights):
            neuron_output += input*weight
        neuron_output += neuron_bias
        outputs.append(neuron_output)

    print(outputs)

    [4.8, 1.21, 2.385]

# Single Neuron using Numpy¶

In [6]:

    import numpy as np

    inputs = [1.0, 2.0, 3.0, 2.5]
    weights = [0.2, 0.8, -0.5, 1.0]
    bias = 2

    output = np.dot(inputs, weights) + bias
    print(output)

    4.8