home scroll deno

AI learning blog November 2023

November 4, 2023

class Neuron contains parameter
self.nonlin = nonlin

The function

def __call__(self, x):
will first calculate and create a new Value act:
act = sum((wi * xi for wi, xi in zip(self.w, x)), self.b)

Depending on the whether nonlin is False or True:

  • If nonlin is False:
  • __call__ will return this Value if nonlin is False.
  • If nonlin is True:
  • __call__ will create another new Value act.relu() and return that new Value

return act.relu() if self.nonlin else act
nonlin=False:

relu_01

nonlin=True:

relu_02


November 5, 2023

Multiplication and Gradient

The gradient of each operand is the data of the other operand times the gradient of the following Value
Here, the total gradient of the weight is
7*7=49

backward_01

When a Value has multiple operations, then the contributions of each gradient are added.
For example, if the operations are multiplications:
def _backward():
self.grad += other.data * out.grad
other.grad += self.data * out.grad
Here, the total gradient of the input is the sum of the products of the weights with the gradients of the following Values
0.3*1 + 0.5*1 = 0.8

backward_01

Here, the total gradient of the input is the sum of the products of the weights with the gradients of the following Values
0.2 * 0.8 + 0.3 * 0.4 = 0.16 + 0.12 = 0.28

backward_03


November 11, 2023

graphviz python User Guide

https://graphviz.readthedocs.io/en/stable/manual.html

November 30, 2023

halfmoom example (in demo.ipynb) uses map function to calculate the activation function for the model:
scores = list(map(model, inputs))
this will call
model(inputs)
several times.
https://www.geeksforgeeks.org/python-map-function/

Date


Follow Me

discord