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
from __future__ import print_function | |
import argparse | |
import torch | |
import torch.utils.data | |
from torch import nn, optim | |
from torch.nn import functional as F | |
from torchvision import datasets, transforms | |
from torchvision.utils import save_image | |
import numpy |
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
{- LANGUAGE UnicodeSyntax -} | |
import Prelude hiding (sum) | |
import Control.Monad | |
import qualified System.Random as R | |
import qualified Data.Map.Strict as M | |
-- | |
-- Define formal power series | |
-- I'm just using lists of coefficients rather than defining a new type. |
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
import System.IO | |
import Data.List | |
rot :: Int -> String -> String | |
rot n s = | |
let (body, tail) = splitAt n s | |
in tail ++ body | |
lookups :: [String] -> [String] -> [String] | |
lookups [] _ = [] |
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
/* | |
* This is a literate quine. That means that | |
* 1. the comments will tell you a little about how it works and | |
* 2. if you compile and run it its output will be identical to its source | |
* code even though it doesn't look at its original source. It literally | |
* contains within itself a complete recipe for how to display itself. | |
* | |
* Quines are ten a penny. This one is unusual because | |
* 1. its main loop consists solely of a loop to print characters | |
* generated by a function called programChar() and |
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
# See https://arxiv.org/abs/1508.06576 | |
import tensorflow as tf | |
import numpy | |
import imageio | |
import scipy.io | |
print "Tensorflow Version", tf.__version__ | |
# Options |
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
import Data.Bits | |
import Control.Monad | |
type Z = Integer | |
-- Find smallest power of two >= given integer. | |
-- Sadly it's not convenient using the usual interface to Integer | |
-- Got exceptions when using Data.Bits.Bitwise | |
suitablePower :: Z -> Int |
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
# Based on http://www.ams.org/notices/201208/rtx120801094p.pdf | |
import math | |
EPS = 1e-8 | |
# Arithmetico-geometric mean | |
def agm(a, b): | |
while True: | |
a1 = 0.5*(a+b) |
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
> import qualified Data.Map as M | |
> vowel :: Char -> Bool | |
> vowel 'a' = True | |
> vowel 'e' = True | |
> vowel 'i' = True | |
> vowel 'o' = True | |
> vowel 'u' = True | |
> vowel _ = False |
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
# See "Self-Normalizing Neural Networks" https://arxiv.org/abs/1706.02515 | |
# "SNNs cannot be derived with...tanh units..." | |
# So I'm probably missing the point somewhere... | |
import math | |
import numpy | |
# Magic number | |
lambda0 = 1.59254 |
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
import math | |
import numpy | |
lambda0 = 1.59254 | |
n = 1000 | |
nlayers = 100 | |
# Incoming activiations have mean 0, variance 1 | |
x = numpy.random.normal(0, 1, n) |