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.optimize import OptimizeResult | |
def sgd( | |
fun, | |
x0, | |
jac, | |
args=(), | |
learning_rate=0.001, |
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
class oset: | |
"""An ordered set which stores elements as the keys of a dict (ordered as | |
of python 3.6). 'A few times' slower than using a set directly for small | |
sizes, but makes everything deterministic. | |
""" | |
def __init__(self, it): | |
self._d = dict.fromkeys(it) | |
@classmethod |
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
def oinsum(eq, *arrays): | |
"""A ``einsum`` implementation for ``numpy`` object arrays. | |
""" | |
import numpy as np | |
import functools | |
import operator | |
lhs, output = eq.split('->') | |
inputs = lhs.split(',') |
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
#!/usr/bin/env python | |
import subprocess | |
print("Finding packages conda says are installed by pip...") | |
conda_raw = subprocess.run( | |
['conda', 'list'], | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE, | |
).stdout.decode('utf-8') |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
\.ipynb_checkpoints/ |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 functools | |
import numpy as np | |
transpose = np.transpose | |
einsum = np.einsum | |
@functools.lru_cache(1) | |
def get_hasher(): |
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 networkx as nx | |
reg = 3 | |
n = 100 | |
seed = 0 | |
gamma0 = -0.743043 | |
beta0 = 0.754082 | |
# create the random graph |
NewerOlder