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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.integrate as integrate | |
# Dimension of image in pixels | |
N = 256 | |
# Number of samples to use for integration | |
M = 33 |
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.Ratio | |
(^+) a b = zipWith (+) a b | |
(^-) a b = zipWith (-) a b | |
(a : as) `convolve` (b : bs) = (a * b) : | |
((map (a *) bs) ^+ (as `convolve` (b : bs))) | |
compose (f : fs) (0 : gs) = f : (gs `convolve` (compose fs (0 : gs))) |
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 DataKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
-- Uses exact-real package | |
import Data.Ratio | |
import Data.CReal | |
(*!) _ 0 = 0 | |
(*!) a b = 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
{-# LANGUAGE FlexibleContexts #-} | |
-- Version 2.0 | |
import Data.Ratio | |
(*!) _ 0 = 0 | |
(*!) a b = a*b | |
(^+) a b = zipWith (+) 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 math | |
import numpy | |
lambda0 = 1.59254 | |
n = 1000 | |
nlayers = 100 | |
# Incoming activiations have mean 0, variance 1 | |
x = numpy.random.normal(0, 1, n) |
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 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
# 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 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
# See https://arxiv.org/abs/1508.06576 | |
import tensorflow as tf | |
import numpy | |
import imageio | |
import scipy.io | |
print "Tensorflow Version", tf.__version__ | |
# Options |