This file contains 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
"""Captures and returns an argument passed to a lambda expression.""" | |
class Capture: | |
"""Captures and returns an argument passed to a lambda expression. | |
:param fn: The lambda expression. | |
:type fn: function | |
:Example: |
This file contains 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 numpy as np | |
class EWMA: | |
"""An exponentially weighted moving average with initialization bias correction.""" | |
def __init__(self, shape=(), dtype=np.float64, beta=0.9, correct_bias=True): | |
self.beta = beta | |
self.beta_accum = 1 if correct_bias else 0 | |
self.value = np.zeros(shape, dtype) |
This file contains 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 pyparsing as pp | |
from pyparsing import pyparsing_common as ppc | |
from repl import repl | |
class Node: | |
def __init__(self, name, *args): | |
self.name = name | |
self.items = args |
This file contains 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 pyparsing as pp | |
from pyparsing import pyparsing_common as ppc | |
from repl import repl | |
variables = {} | |
var = ppc.identifier.copy() | |
def do_var(t): |
This file contains 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
"""Converts between the RGB and CIECAM02 color spaces.""" | |
from collections import namedtuple | |
from functools import partial | |
import colour | |
from colour.utilities import tsplit, tstack | |
import numpy as np | |
from scipy.optimize import fmin_l_bfgs_b |
This file contains 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
"""Converts colors from HSL to RGB and back.""" | |
import numpy as np | |
from scipy import optimize | |
def tstack(a): | |
"""Stacks arrays in sequence along the last axis (tail).""" | |
a = np.asarray(a) | |
return np.concatenate([x[..., np.newaxis] for x in a], axis=-1) |
This file contains 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 argparse | |
from functools import partial, reduce | |
import math | |
from pathlib import Path | |
import random | |
from keras.layers import * | |
from keras.models import Model | |
from keras.utils import io_utils |
This file contains 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
name: "VGG_ILSVRC_16_layers_conv" | |
force_backward: true | |
layer { | |
name: "data" | |
type: "Input" | |
top: "data" | |
input_param { shape: { dim: 1 dim: 3 dim: 224 dim: 224 } } | |
} | |
layer { | |
bottom: "data" |
This file contains 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 numpy as np | |
from scipy.linalg import blas | |
from scipy.ndimage import zoom | |
# Machine epsilon for float32 | |
EPS = np.finfo(np.float32).eps | |
# pylint: disable=no-member | |
def dot(x, y): |
This file contains 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
--[[ An experimental quasi-Newton optimizer. | |
Incorporates Hessian damping, momentum, and per-feature learning rate scaling. | |
Also implements optional polynomial-decay averaging (similar to ASGD). | |
ARGS: | |
- 'opfunc' : a function that takes a single input (X), the point | |
of a evaluation, and returns f(X) and df/dX | |
- 'x' : the initial point | |
- 'config` : a table with configuration parameters for the optimizer |