2026-03-12 12:34:11 -05:00

30 lines
818 B
Python

import numpy as np
#inputs * weights + biases = predictions
inputs = [[1.0, 2.0, 3.0, 2.5],
[2.0, 5.0, -1.0, 2.0],
[-1.5, 2.7, 3.3, -0.8]]
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.0, 3.0, 0.5]
#adding more sets of weights and biases creates more layers for our neural network
weights2 = [[0.1, -0.14, 0.5],
[-0.5, 0.12, -0.33],
[-0.44, 0.73, -0.13]]
biases2 = [-1, 2, -0.5]
#take dot product of the two matrices and add biases (transpose so that we can do matrix multiplication)
layer_outputs = np.dot(inputs, np.array(weights).T) + biases
#repeat dot product but instead with the output matrix from layer1 and the second layer of weights and biases
layer_outputs2 = np.dot(layer_outputs, np.array(weights2).T) + biases2
print(layer_outputs2)