2026-06-22 · Rust Learning week 3
So I started on this journey realizing I had no idea what the functions I was calling were doing. I'd apply a softmax to some values that seemed very random to me following documentation, writing in my notes what intuitively everything did but I truely didn't understand what I was writing.I've been working on MSE, matrix multiplication, dot products, relu, and then working that together to create a super simply feed forward network.
Basically I'm building myself up from the basics so that I have a strong understanding of how everything works.
It worked super nicely because I'd build in the bias function, the ReLu, and dot products and then on the very next mini challenge, use my old code for the new problem.
pub fn matmul(...) { ...}
pub fn add_bias(...) {...}
pub fn relu(...) {...}
pub fn dense_forward(
x: Vec<Vec<f32>>,
w: Vec<Vec<f32>>,
b: Vec<f32>,
) -> Option<Vec<Vec<f32>>> {
if x.is_empty() || w.is_empty() || b.is_empty() {
return None;
}
let z = Self::matmul(x, w);
let z_b = Self::add_bias(z?, b);
let y = Self::relu(z_b?);
Some(y)How I've been learning thusfar: I've been leaning on AI to roadmap my progression from skillset to skillset and have it generate LeatCode style files for me to build ML stuff. It's been working great but I'm hoping I can reach out to someone more senior for some guidance on how they'd go from here.
fn main() {
println!("\x1b[1m\x1b[35mNN Runner: Dense Layer Forward\x1b[0m");
// Identity-like layer, no bias
print_result(
"Test Case 1",
vec![vec![1.0, 2.0]],
vec![vec![1.0, 0.0], vec![0.0, 1.0]],
vec![0.0, 0.0],
Some(vec![vec![1.0, 2.0]]),
);
// ...
}2026-06-11 · Rust Learning Day 1
Lot's of confusion but my focus has been to avoid LLM code like it's the plague. Autocorrect is off and so is Copilot.
I'm reading through the amazing Rust documentation along with doing Leatcode problems.
As for the use of AI, I've been using Perplexity.ai for choosing Leatcode problems and writing tests for them exlcusively.
All code is human written. I've loved the look of Rust code and I always imitate it in Python anyways so I'm hoping this keeps up. It's a little bit of a learning curve. As long as I keep challenging myself and going through the docs I'll eventually learn.
The syntax too is starting to make sense but I have to think about it.
Vec<i32> // Right cos Vector = Array = List and i32 interger 32 bits for i in 0..nums.len() // 0..nums like the ... in math and .len() is an improvement -> Vec<i32> // is also phenominal because no typing library is required return // Early return and auto returning is amazingStill wrapping my head around som errors with pointers and borrowing. Anyways did two Leatcode problems in rust.
impl Solution { pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { for i in 0..nums.len() { for j in (i+1)..nums.len() { if nums[i] + nums[j] == target { return vec![i as i32, j as i32]; } } } } } // Which I optimized using hashmaps to use std::collections::HashMap; let mut map: HashMap<i32, usize> = HashMap::new(); for (i, &val) in nums.iter().enumerate() { let mut complement = target - val; if let Some(&j) = map.get(&complement) { return vec![j as i32, i as i32]; } else { map.insert(val, i); } } // & impl Solution { pub fn is_palindrome(s: String) -> bool { let filtered: String = s .to_lowercase() .chars() .filter(|c| c.is_alphanumeric()) .collect(); let reversed: String = filtered .chars() .rev() .collect(); filtered == reversed } }
2026-06-11 · Rust Learning Day 3
Today I worked on a medium difficulty leatcode problem. It went pretty well but I learned some new syntax. This was a command I used quite a lot in Python but getting familiar with it in Rust was nice.
let x = 3
let y = 4
x.max(y)
// Output: 4I had already solved the Leatcode problem beforehand but the solution used max and it greatly simplified my code.
I'm also noticing that writing in Rust has already started becoming very natural to me. It's a lot like python in certain ways at least the way I write my Python code—with a little too much perfectionism.
2026-06-12 · Rust Learning Day 3
// ❌let mut log: Vec<i32> = vec![]; because idx will be usize?!?!
// so instead:
let mut log: Vec<usize> = vec![];
// ...
for (idx, x) in nums.iter().skip(1).enumerate() {
// ...
log.push(idx + 1); // now works
}Then I'm starting to learn about the borrowing system which feels confusing right now but I'm already starting to see the logic behind it.
let mut current: i32 = nums[0];
for (idx, x) in nums.iter().skip(1).enumerate() {
if current < *x {
// ... prevents errors by adding *x because current is i32 and
// x is a reference to a value
}
}But there's a better solution
let mut current: i32 = nums[0];
for (idx, &x) in nums.iter().skip(1).enumerate() {
if current < x {
// ... Here by borrowing we avoid the missmatched type issue
// because we borrow from x
}
}2026-06-23 · Rust Learning week 4
Softmax has kinda just been this mysterious function I'd call to turn this seemingly abitrary numbers into probablilities. Now I understand how it funcitons. It's really clean and also cool that it uses e a lot because that means the derative will be interesting to learn about later on down the road for maybe backprop.
So for softmax, the problem I did was a row by row softmax calculation. I wrote a general function, and then this sub function:
pub fn softmax_row(xs: &Vec<f32>) -> Vec<f32> {
let mut denominator = 0.0_f32;
let mut out = Vec::new();
for j in xs {
denominator += j.exp();
}
for i in xs {
out.push( i.exp() / denominator);
}
out
}I decided to calculate the denominator first because I realized that exponential equations can take up a lot of memory and down the road that will be a concern once the numbers are larger. Basically I pulled up Victor Zhou's amazing article and implemented in Rust. Super cool dude! Basically copied this equation.
Other learnings:
Vec::new(); // I'm prefering this over vec![]; currently
for row in &matrix { ... } // because row inherits the val from matrix
// it must be borrowed instead of just for row in matrix
let x = 43.32_f32; // Learned that I can just do _f32 and it's pretty