Sumanth Profile picture
Jul 25, 2023 9 tweets 3 min read Read on X
Neural Network implemented from scratch in Python🔥

Here is the step by step explanation with code.

Thread🧵👇 Image
Below is the simple Neural Network consists of 2 layers:

- Hidden Layer
- Output Layer

First Initialize the size of layers along with the weights & biases.

And also define the sigmoid activation function & it's derivative which is really key to introduce non-linearity. Image
Forward Pass:

Here the input data is passed through the neural network to obtain the predicted output.

In forward pass, First calculate the output of the hidden layer.

hidden_output = X•W1 + b1

Then apply the sigmoid activation to the output.

output = sigmoid( (X•W1) + b1) Image
Backward Pass:

First compute the gradients of the output layer.

Loss = (y - output)

Gradient of Loss = (y - output) * sigmoid_derivative(output)

Now calculate d_W2 which is gradient of the loss function with respect to W2.

d_W2 = hidden_output.T • Gradient of Loss Image
Similarly calculate d_W1, d_b2 & d_b1

dW1: Gradient of the loss function wrt W1

d_b2: Gradient of the loss function wrt b2(bias of neuron in output layer)

d_b1: Gradient of the loss function wrt b1(bias of neuron in hidden layer) Image
Now Update the Weights:

Here learning rate is the hyper parameter!

A low learning rate can cause the model getting caught in local optima, while the high learning rate can cause the model to overshoot the general solution

W1 += learning_rate * d_W1
b1 += learning_rate * d_b1 Image
Now a method to train the neural network using both the forward and backward passes.

The function will run for specified no of epochs, calculating:

1. The Forward Pass
2. Backward Pass
3. Updating the Weights Image
Finally the Predict Function

Now to predict on any new data all we need to do is a single Forward Pass through the Network: Image
That's a wrap!

Every day, I share and simply content around Python, Data Science, Machine Learning & Large Language Models.

Find me → @Sumanth_077 ✅

Like/RT the first tweet and help this reach more people.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Sumanth

Sumanth Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Sumanth_077

Aug 30
9 GitHub Repositories that will give you superpowers as an AI Engineer:
1. Build a Large Language Model from scratch

This repository contains the code examples for developing, pretraining, and finetuning a LLM from scratch.

It is the official codebase for the book Build a Large Language Model (From Scratch).

- Github Repo: github.com/rasbt/LLMs-fro…
2. Hands on Large Language Models

This repository contains the complete code examples from the book Hands-On Large Language Models.

It includes notebook examples that cover everything from the introduction to language models to fine-tuning them.

- Github Repo: github.com/HandsOnLLM/Han…
Read 11 tweets
Aug 23
AI agents don't need bigger models, they need better context!

You can now make Claude Code, Gemini CLI, and other coding agents 10x more powerful by giving them the right context.

Here’s a step‑by‑step breakdown:
Context engineering is about delivering the right information and tools in the right format so LLMs can perform reliably.

Most of the time when agents fail, it’s not the model but missing context or tools that prevent reliable performance.

Let’s see how to set that up.
In this tutorial, we’ll use Byterover, a Central Memory Layer for coding agents and dev teams.

You can connect it with Claude Code, Gemini CLI, or VS Code, Cursor, and Windsurf as a plugins.

Let's see how to integrate it to Gemini CLI.

byterover.dev/?source=sm4
Read 9 tweets
Jul 30
You can now make Claude Code, Gemini CLI, and other coding agents 10x more powerful by giving them long‑term memory!

It just takes a single line of code.

Here’s a step‑by‑step breakdown (100% local):
Coding agents have a major limitation: they forget everything between sessions.

Without memory, they can’t retain project context, past fixes, or key decisions.

What they need is a persistent memory layer to store and recall context.

Let’s see how to set that up.
We’ll use Cipher, an open‑source memory layer for coding agents.

You can run Cipher as an MCP server so coding agents like Claude Code, Gemini CLI, or plugins for VS Code, Cursor, and Windsurf can connect directly and use its memory layer out of the box

github.com/campfirein/cip…
Read 9 tweets
Jul 6
10 GitHub Repositories you should definitely check as an AI Engineer:
1. Hands on Large Language Models

This repository contains notebook examples that cover everything from the introduction to language models to fine-tuning them.

Check this out: github.com/HandsOnLLM/Han…
2. AI Agents for Begineers

Beginner friendly course on AI Agents

This Free 11-lesson course will teach you everything you need to get started with building AI agents.

Check this out: github.com/microsoft/ai-a…
Read 12 tweets
Jun 22
5 MCP, RAG & Agents projects for AI Engineers:
1. Agentic RAG

Build a RAG pipeline with agentic capabilities that can dynamically fetch context from different sources, like a vector DB and the internet.

Check this out: github.com/patchy631/ai-e…
2. MCP-powered RAG over videos

Learn how to build a video RAG that ingests a video and lets you chat with it. It also fetches the exact video chunk where an event occurred.

Check this out: github.com/patchy631/ai-e…
Read 8 tweets
May 25
Microsoft released an AI powered data analysis tool!

Data Formulator is an AI-powered tool for analysts to iteratively create rich visualizations.

It's no-code & 100% open-source Image
If you found it useful, reshare it with your network.

Follow me → @Sumanth_077 for more such content and tutorials on ML, LLMs and AI Agents!

Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(