This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |