Skip to content

Instantly share code, notes, and snippets.

View martinferianc's full-sized avatar
👋
Hi!

Martin Ferianc martinferianc

👋
Hi!
View GitHub Profile
@lromor
lromor / tinyimagenet.py
Last active February 6, 2025 17:08
TinyImageNet Dataset for Pytorch
# 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
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
@z-a-f
z-a-f / tin.py
Created July 31, 2019 16:31
Tiny ImageNet Dataset for PyTorch
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"""
@lgeiger
lgeiger / adamirror.py
Created May 7, 2018 10:55
Training GANs with Optimism using Tensorflow (https://github.com/vsyrgkanis/optimistic_GAN_training/)
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
@dpressel
dpressel / highway.py
Last active June 8, 2020 17:18
Highway layer using PyTorch
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)
@vvanirudh
vvanirudh / bayes_by_backprop.py
Last active July 25, 2022 11:26
Bayes by Backprop in PyTorch (introduced in the paper "Weight uncertainty in Neural Networks", Blundell et. al. 2015)
# 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
@dpressel
dpressel / highway.py
Last active June 8, 2020 17:18
Highway Connections in TensorFlow
# 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
@GaelVaroquaux
GaelVaroquaux / mutual_info.py
Last active June 18, 2023 12:25
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
'''
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.