Skip to content

Instantly share code, notes, and snippets.

View ryanzidago's full-sized avatar

Ryan Zidago ryanzidago

View GitHub Profile
@ryanzidago
ryanzidago / fastbook_chapter_4-customer_learner.py
Last active September 19, 2021 18:10
Fastbook Chapter 4 - Custom Learner
def mnist_loss(predictions, targets):
predictions = predictions.sigmoid()
return torch.where(targets == 1, 1 - predictions, predictions).mean()
class BasicOptim:
def __init__(self, params, learning_rate):
self.params = params
self.learning_rate = learning_rate
def step(self, *args, **kwargs):
@ryanzidago
ryanzidago / roman_numerals.exs
Created April 11, 2020 20:47
Here is my solution to Exercism's Roman Numerals exercise.
defmodule RomanNumerals do
import IO, only: [iodata_to_binary: 1]
@doc """
Convert the number to a roman number.
"""
@spec numeral(pos_integer) :: String.t()
def numeral(0), do: ""
def numeral(1), do: "I"
def numeral(2), do: "II"