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
# Copyright (C) 2022 Leonardo Romor | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 jax | |
import jax.numpy as np | |
from jax.experimental import stax | |
from jax.experimental import optimizers | |
from jax.experimental.stax import Dense, Relu, Tanh, Softmax, LogSoftmax | |
from jax import jit, grad, random | |
import time | |
import itertools |
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 imageio | |
import numpy as np | |
import os | |
from collections import defaultdict | |
from torch.utils.data import Dataset | |
from tqdm.autonotebook import tqdm | |
dir_structure_help = r""" |
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 absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
from tensorflow.python.eager import context | |
from tensorflow.python.ops import control_flow_ops | |
from tensorflow.python.ops import math_ops | |
from tensorflow.python.ops import state_ops | |
from tensorflow.python.framework import ops | |
from tensorflow.python.training import optimizer |
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 torch | |
import torch.nn as nn | |
class Highway(nn.Module): | |
def __init__(self, input_size): | |
super(Highway, self).__init__() | |
self.proj = nn.Linear(input_size, input_size) | |
self.transform = nn.Linear(input_size, input_size) | |
self.transform.bias.data.fill_(-2.0) |
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
# Drawn from https://gist.github.com/rocknrollnerd/c5af642cf217971d93f499e8f70fcb72 (in Theano) | |
# This is implemented in PyTorch | |
# Author : Anirudh Vemula | |
import torch | |
import torch.nn as nn | |
from torch.autograd import Variable | |
import numpy as np | |
from sklearn.datasets import fetch_mldata |
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 stack of res conns | |
def skip_conns(inputs, wsz_all, n): | |
for i in range(n): | |
with tf.variable_scope("skip-%d" % i): | |
W_p = tf.get_variable("W_p", [wsz_all, wsz_all]) | |
b_p = tf.get_variable("B_p", [1, wsz_all], initializer=tf.constant_initializer(0.0)) | |
proj = tf.nn.relu(tf.matmul(inputs, W_p) + b_p, "relu") | |
inputs = inputs + proj |
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
''' | |
Non-parametric computation of entropy and mutual-information | |
Adapted by G Varoquaux for code created by R Brette, itself | |
from several papers (see in the code). | |
This code is maintained at https://github.com/mutualinfo/mutual_info | |
Please download the latest code there, to have improvements and | |
bug fixes. |