Export File Type Tests
This commit is contained in:
parent
22ea946f16
commit
bda88776f7
7755
lecture01/lecture_01.html
Normal file
7755
lecture01/lecture_01.html
Normal file
File diff suppressed because one or more lines are too long
BIN
lecture01/lecture_01.pdf
Normal file
BIN
lecture01/lecture_01.pdf
Normal file
Binary file not shown.
82
lecture01/lecture_01.py
Normal file
82
lecture01/lecture_01.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# %% [markdown]
|
||||||
|
# # Neuron with 3 inputs
|
||||||
|
|
||||||
|
# %%
|
||||||
|
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}")
|
||||||
|
|
||||||
|
# %% [markdown]
|
||||||
|
# # Neuron with 4 inputs
|
||||||
|
|
||||||
|
# %%
|
||||||
|
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)
|
||||||
|
|
||||||
|
# %% [markdown]
|
||||||
|
# # Layer of 3 neurons with 4 inputs
|
||||||
|
|
||||||
|
# %%
|
||||||
|
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)
|
||||||
|
|
||||||
|
# %% [markdown]
|
||||||
|
# # Layer of 3 neurons with 4 inputs
|
||||||
|
|
||||||
|
# %%
|
||||||
|
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)
|
||||||
|
|
||||||
|
# %% [markdown]
|
||||||
|
# # Single Neuron using Numpy
|
||||||
|
|
||||||
|
# %%
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user