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
def sample_dball_uniform(n_points=1000, n_dims=3): | |
"""Sample uniformly from d-dimensional ball | |
The code is inspired by this small note: | |
https://blogs.sas.com/content/iml/2016/04/06/generate-points-uniformly-in-ball.html | |
https://www.sciencedirect.com/science/article/pii/S0047259X10001211 | |
Parameters | |
---------- | |
n_points : 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
def random_number_generator(arg1, arg2): | |
""" | |
Summary line. | |
Extended description of function. | |
Parameters | |
---------- | |
arg1 : int | |
Description of arg1 |
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 os | |
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | |
PROJECT_DIR = os.path.dirname(SCRIPT_DIR) | |
LOG_DIR = os.path.join(PROJECT_DIR, 'logs') |
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 numpy as np | |
def count_conv_params_flops(conv_layer, verbose=1): | |
# out shape is n_cells_dim1 * (n_cells_dim2 * n_cells_dim3) | |
out_shape = conv_layer.output.shape.as_list() | |
n_cells_total = np.prod(out_shape[1:-1]) | |
n_conv_params_total = conv_layer.count_params() |
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 keras.backend as K | |
import numpy as np | |
def gaussian_nll(ytrue, ypreds): | |
"""Keras implmementation of multivariate Gaussian negative loglikelihood loss function. | |
This implementation implies diagonal covariance matrix. | |
Parameters | |
---------- |
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
#http://www.svcl.ucsd.edu/courses/ece161c/handouts/DCT.pdf | |
import numpy as np | |
import matplotlib.pyplot as plt | |
pi = np.pi | |
N = 50 # timesteps | |
k = 10 # n basis functions |
NewerOlder