Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on. You've got this! 🚀
Inputs and Outputs
Inputs are the raw data fed into the neural network. Outputs are what the network produces after processing. Understanding the shape of inputs and outputs helps you design networks for specific tasks.
What Inputs Look Like
Neural networks work with numbers. Everything must be converted to numbers before it can be processed.
Images: each pixel becomes a number (0 to 255 for brightness)
Text: each word or character gets a numerical code
Audio: sound waves are sampled into sequences of numbers
Tabular data: each column value is already a number or is converted to one
For a 28x28 pixel grayscale image (like handwritten digits), the input is 784 numbers (28 times 28).
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
What Outputs Look Like
- For classification (cat vs dog): output is probabilities for each class. Example: [0.85, 0.15] means 85% cat, 15% dog
- For regression (house price): output is a single number. Example: 245000 (dollars)
- For text generation: output is a probability for each word in the vocabulary
- For image segmentation: output is a label for each pixel
Input to Output Example
# Show how data flows from input to output
# Example: simple image classifier (3x3 grayscale image)
# Each pixel has a value 0 (black) to 1 (white)
image_3x3 = [
[0.1, 0.9, 0.1], # row 1
[0.9, 0.9, 0.9], # row 2 (bright center)
[0.1, 0.9, 0.1], # row 3
]
# Flatten image: convert 2D grid to 1D list (network input)
inputs = [pixel for row in image_3x3 for pixel in row]
print(f"Image size: 3x3 = {len(inputs)} input values")
print(f"Inputs: {[round(x, 1) for x in inputs]}")
print()
# The network produces output probabilities
# (In real networks, these are calculated through layers of neurons)
# Here we show what the output represents
output_probabilities = [0.05, 0.92, 0.03] # example output
classes = ["triangle", "cross", "circle"]
print("Output probabilities:")
for class_name, prob in zip(classes, output_probabilities):
bar = "=" * int(prob * 20)
print(f" {class_name:10}: {prob:.2f} |{bar}|")
print()
predicted_class = classes[output_probabilities.index(max(output_probabilities))]
print(f"Predicted class: {predicted_class} ({max(output_probabilities)*100:.0f}% confidence)")Key Takeaways
- Inputs are the raw data fed into the neural network.
- For classification (cat vs dog): output is probabilities for each class. Example: [0.85, 0.15] means 85% cat, 15% dog
- For regression (house price): output is a single number. Example: 245000 (dollars)
- For text generation: output is a probability for each word in the vocabulary