Skip to content

Instantly share code, notes, and snippets.

Avatar

Federico Lebrón fedelebron

View GitHub Profile
@fedelebron
fedelebron / dog-classifier-part-2-colab-edition.ipynb
Last active Sep 28, 2021
Dog Classifier, part 2 - Colab edition
View dog-classifier-part-2-colab-edition.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fedelebron
fedelebron / dog-classifier.ipynb
Last active Sep 17, 2021
Transfer learning CNNs with JAX, part 1
View dog-classifier.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View dog-classifier-colab-edition.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View dog-classifier-colab-edition.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View dog-classifier-colab-edition.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View dog-classifier-colab-edition.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fedelebron
fedelebron / rho-property
Last active Nov 5, 2019
Short demo of a lambda calculus curiosity, from Mirai Ikebuchi, Keisuke Nakano "On repetitive right application of B-terms" 2018
View rho-property
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Set as S
import Data.String
import Data.List
type Var = String
data Expr = V Var | Ap Expr Expr | Lambda Var Expr
deriving Eq
@fedelebron
fedelebron / Permanent.hs
Created Aug 19, 2013
A function to compute the permanent of a matrix in Haskell. The algorithm is not as efficient as it could be - it is using the Ryser formula for an O(n^2 * 2^n) runtime, where a O(n * 2^n) algorithm exists, which uses the same idea but adds Gray codes to compute the subsets in a better order, allowing a reuse of computations.
View Permanent.hs
{-# LANGUAGE FlexibleContexts #-}
import Data.Array.IArray (IArray, bounds)
import Data.Array.Unboxed (UArray)
import Data.Array.Base (unsafeAt)
import Data.Bits (popCount, testBit)
permanent :: (Integral a, IArray UArray a) => UArray (Int, Int) a -> a
permanent arr | n == m = (if even n then negate else id) (sum entries)
where
((0, 0), (n, m)) = bounds arr
@fedelebron
fedelebron / eratosthenes.cpp
Last active Dec 16, 2015
A small implementation of Eratosthenes' sieve.
View eratosthenes.cpp
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<bool> composite(n);
composite[0] = true; // Technically a zero divisor
composite[1] = true;
for (int i = 2; i*i < n; ++i) {
@fedelebron
fedelebron / MillerRabin.cpp
Created Apr 7, 2013
A small implementation of the Miller-Rabin primality test. This version is deterministic and correct for numbers up to 2,152,302,898,747.
View MillerRabin.cpp
typedef long long tint;
tint powmod(tint a, tint k, tint n) {
tint b = 1;
while (k) {
if (k & 1) {
--k;
b = (b * a) % n;
} else {
k >>= 1;