Step 1: Getting To Know AI
What is AI?
Artificial Intelligence (AI) means teaching computers to think and learn like humans. Instead of just following exact instructions, AI can make decisions, recognize patterns, and improve over time. It powers things like voice assistants, recommendation systems, and self-driving cars.
What will this tutorial cover?
In this tutorial, you'll learn how to build a basic AI from scratch. We'll start simple and build up step-by-step:
- Step 1: Understand what AI really is and how it works.
- Step 2: Create a basic neuron, which is the building block of AI, that can convert inputs to outputs.
- Step 3: Connect multiple neurons to make your AI smarter and able to solve more complex problems.
By the end, you'll have a clear understanding of how AI works at its core and how to create your own simple AI models!
AI Assistant - Step 2: Basic Nueron
A simple nueron works by taking in a string of numbers such as ASCII or other variables, then applying a weight and balance to the numbers to get an output. Tuning these weights and balances allows for the AI to develop the idea of what you want the input to mean. For this tutorial we will be using Numpy with Python to make the basic neuron. Lets get started!
- First we will import Numpy.
- Next we will define our neuron class. We will add our init function which will define our weights, biases, and input values.
- Next we will add our activation function. This is the function that will take in our inputs and apply the weights and biases to get an output.
- Now we will implement a ReLu function which will allow us to get a positive output from our neuron.
- Finally we will create an instance of our neuron and test it with some inputs.
import numpy as np
import numpy as np
class Neuron:
def __init__(self, bias, weights):
self.bias = bias
self.weight = weights
self.inputs = None
import numpy as np
class Neuron:
def __init__(self, bias, weights):
self.bias = bias
self.weight = weights
self.inputs = None
def activation_function(self, inputs):
self.inputs = inputs
output = np.dot(self.inputs, self.weight) + self.bias
return output
import numpy as np
class Neuron:
def __init__(self, bias, weights):
self.bias = bias
self.weight = weights
self.inputs = None
def activation_function(self, inputs):
self.inputs = inputs
output = np.dot(self.inputs, self.weight) + self.bias
return self.relu(output)
def relu(self, x):
return 1 / (1 + np.exp(-x))
import numpy as np
class Neuron:
def __init__(self, bias, weights):
self.bias = bias
self.weight = weights
self.inputs = None
def activation_function(self, inputs):
self.inputs = inputs
output = np.dot(self.inputs, self.weight) + self.bias
return self.relu(output)
def relu(self, x):
return 1 / (1 + np.exp(-x))
if __name__ == "__main__":
bias = 0.5
weights = np.array([0.2, 0.8, -0.5])
neuron = Neuron(bias, weights)
inputs = np.array([1.0, 0.5, -1.0])
output = neuron.activation_function(inputs)
print("Neuron output:", output)
And that's it! You have created a basic neuron that can take in inputs, apply weights and biases, and return an output. You can now use this neuron to build more complex neural networks.
AI Assistant - Step 3: Multiple Neurons
Template stuff to be implemented later