Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11You can build a small neural network without PyTorch using only Python’s built-in features. This walkthrough implements XOR with nested lists, sigmoid activations, mean squared error, backpropagation, and gradient descent. It assumes you already know basic Python; it does not assume prior machine-learning experience.
“Without PyTorch” does not necessarily mean “without libraries.” This example uses no third-party libraries, so the arithmetic and parameter updates stay visible. The Python Tutorial is intended for programmers new to Python, not people new to programming, and notes that hands-on access to an interpreter is helpful.
What the network will learn
The example trains a small network to reproduce XOR: its output is 1 when its two inputs differ, and 0 when they match. A single linear decision boundary cannot separate XOR’s two positive cases from its two negative cases. A hidden layer with a nonlinear activation lets the network combine features in a way that can represent this pattern. University teaching materials use XOR to teach multilayer networks and backpropagation, including the University of Göttingen course on deep neural networks and training and the University of Tübingen Deep Learning curriculum.
The network has two input values, a hidden layer of two neurons, and one output neuron. Each neuron computes a weighted sum of its inputs plus a bias, then applies an activation function. The layers compose these operations to turn inputs into a prediction.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
| Part | Shape | Meaning |
|---|---|---|
| Input | 2 values | The two bits in an XOR example |
| Input-to-hidden weights | 2 × 2 | Two input weights for each of two hidden neurons |
| Hidden biases | 2 values | One bias per hidden neuron |
| Hidden-to-output weights | 2 × 1 | One weight from each hidden neuron to the output |
| Output bias | 1 value | The output neuron’s bias |
These are nested Python lists rather than NumPy arrays. Python’s documentation shows nested lists representing a matrix and demonstrates built-in sequence operations such as transposing one with zip(*matrix) in its data structures guide. Here, explicit loops make each calculation easy to inspect.
Define the data, activation, and parameters
For simplicity, each example is one row and the target is a single number. The sigmoid function squashes a real-valued input into the interval (0, 1), which makes the output usable as a prediction between the two XOR labels.
data = [
([0.0, 0.0], 0.0),
([0.0, 1.0], 1.0),
([1.0, 0.0], 1.0),
([1.0, 1.0], 0.0),
]
def sigmoid(x):
return 1.0 / (1.0 + __import__("math").exp(-x))
def sigmoid_derivative_from_output(y):
return y * (1.0 - y)
# Weights are arranged as [input index][hidden neuron index].
w1 = [
[-0.4, 0.2],
[ 0.3, -0.5],
]
b1 = [0.1, -0.2]
# One weight per hidden neuron, feeding the single output.
w2 = [0.4, -0.3]
b2 = 0.2
The starting parameters are fixed here so the initial forward-pass example is reproducible. Training results still depend on the starting values, learning rate, update order, and number of passes through the data. The code imports no libraries for data handling or learning; the activation uses Python’s built-in math module.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Run one forward pass
For input [0, 1], the first hidden neuron’s weighted sum is 0 × -0.4 + 1 × 0.3 + 0.1 = 0.4. Applying sigmoid gives approximately 0.599. The second hidden neuron’s sum is 0 × 0.2 + 1 × -0.5 - 0.2 = -0.7, whose sigmoid is approximately 0.332. The output neuron then applies sigmoid to 0.599 × 0.4 + 0.332 × -0.3 + 0.2, producing approximately 0.575.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →That is the network’s initial prediction for a target of 1. It is not yet a good XOR model. The function below calculates the same sequence for any input.
def forward(x):
hidden = []
for j in range(2):
z = x[0] * w1[0][j] + x[1] * w1[1][j] + b1[j]
hidden.append(sigmoid(z))
z_out = hidden[0] * w2[0] + hidden[1] * w2[1] + b2
prediction = sigmoid(z_out)
return hidden, prediction
hidden, prediction = forward([0.0, 1.0])
print(hidden, prediction)
Measure prediction error
Use squared error for one example: 0.5 × (prediction − target)². The factor of 0.5 cancels the 2 that appears when differentiating the square. For a set of examples, the training loop below reports mean squared error without the 0.5 factor; the choice of reporting scale does not change the gradient updates used in the loop.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
For the worked input, prediction is about 0.575 and target is 1, so the squared-error loss with the half factor is about 0.5 × (0.575 − 1)². Loss turns a prediction into a single measure of how far it is from its target; the gradient tells us which direction to change parameters to reduce that loss.
Backpropagate gradients and update parameters
Backpropagation applies the chain rule: it works from the output toward earlier layers to calculate how each weight and bias affects loss. Let y be the prediction and t the target. With the half-squared loss and sigmoid output, the output error term is (y − t) × y × (1 − y). The sigmoid derivative can be calculated from its output as y × (1 − y).
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches- For an output weight connected to hidden activation
h, the gradient is the output error term multiplied byh. - The output-bias gradient is the output error term itself.
- For a hidden neuron, its error term is the output error term multiplied by its outgoing weight and by the derivative of that hidden neuron’s sigmoid.
- Each input-to-hidden weight gradient is the hidden error term multiplied by its corresponding input; the hidden-bias gradient is the hidden error term.
Gradient descent subtracts the learning rate times each gradient from the associated parameter. The function below calculates gradients using the current weights, then updates them. In particular, it computes hidden-layer gradients before changing the output weights, so all gradients belong to the same forward pass.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
def train_one(x, target, learning_rate):
global w1, b1, w2, b2
hidden, y = forward(x)
output_delta = (y - target) * sigmoid_derivative_from_output(y)
# Calculate hidden deltas using the pre-update output weights.
hidden_deltas = [
output_delta * w2[j] * sigmoid_derivative_from_output(hidden[j])
for j in range(2)
]
# Output-layer gradients and updates.
for j in range(2):
grad_w2 = output_delta * hidden[j]
w2[j] -= learning_rate * grad_w2
b2 -= learning_rate * output_delta
# Input-to-hidden gradients and updates.
for i in range(2):
for j in range(2):
grad_w1 = hidden_deltas[j] * x[i]
w1[i][j] -= learning_rate * grad_w1
for j in range(2):
b1[j] -= learning_rate * hidden_deltas[j]
return 0.5 * (y - target) ** 2
This is the core training operation: forward pass, loss-related gradients, then parameter update. The training loop repeats it over examples. It uses a fixed order for the four rows; changing order or learning rate can change the result.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Train and inspect predictions
Run repeated passes through the four XOR examples. The code prints initial predictions, then trains for a chosen number of epochs and prints the predictions afterward. The initialization and hyperparameters are explicit, but no particular final accuracy or training time is promised: those outcomes depend on the chosen parameters and execution.
def predict(x):
return forward(x)[1]
print("Before:")
for x, target in data:
print(x, "target:", target, "prediction:", predict(x))
learning_rate = 1.0
epochs = 10000
for epoch in range(epochs):
for x, target in data:
train_one(x, target, learning_rate)
print("After:")
for x, target in data:
print(x, "target:", target, "prediction:", predict(x))
The printed outputs are continuous values, not forced labels. To classify them as XOR bits, a simple threshold would label predictions at least 0.5 as 1 and lower values as 0. A training example is not evidence that the implementation generalizes beyond this tiny dataset.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
What this implementation leaves out
A hand-written two-layer network exposes the mechanics, but it is not a substitute for the infrastructure needed to train large models or run production workloads.
- There is no automatic differentiation: gradients must be derived and coded manually.
- There is no batching or general tensor-shape machinery; this example processes one row at a time.
- There is no validation split, regularization, numerical-stability handling for extreme sigmoid inputs, or robust model evaluation.
- There is no hardware acceleration or framework-managed optimizer; the parameters and update rule are the code shown above.
NumPy can shorten array arithmetic and make shape-oriented calculations more convenient, while still leaving the learning algorithm visible. A framework such as PyTorch goes further by supplying automatic differentiation and broader support for optimization, batching, and hardware. The title’s promise is specifically no PyTorch; this example additionally chooses to use only Python built-ins.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

