Skip to content

Instantly share code, notes, and snippets.

Avatar

Kashif Rasul kashif

View GitHub Profile
@kashif
kashif / batch_SGDEN.py
Last active Sep 7, 2020
Batch SGD ElasticNet
View batch_SGDEN.py
from sklearn.datasets import load_boston
from sklearn.linear_model import (LinearRegression, Ridge, SGDRegressor,
Lasso, ElasticNetCV)
from sklearn.preprocessing import MinMaxScaler
import numpy as np
#from minepy import MINE
from sklearn.metrics import mean_squared_error
@kashif
kashif / batch_EN.py
Last active Sep 7, 2020
Batch ElasticNet
View batch_EN.py
from sklearn.datasets import load_boston
from sklearn.linear_model import (LinearRegression, Ridge, LassoCV, ElasticNetCV,
ElasticNet, Lasso, RandomizedLasso)
from sklearn.feature_selection import RFE, f_regression
from sklearn.preprocessing import MinMaxScaler
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor
import numpy as np
import pdb
#from minepy import MINE
View batch_embedded_GBRT.py
from sklearn.datasets import load_boston
from sklearn.linear_model import (LinearRegression, Ridge,
Lasso, RandomizedLasso)
from sklearn.feature_selection import RFE, f_regression
from sklearn.preprocessing import MinMaxScaler
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor
import numpy as np
#from minepy import MINE
from sklearn.metrics import mean_squared_error
View evonorm2d.py
import torch
import torch.nn as nn
class EvoNorm2d(nn.Module):
__constants__ = ['num_features', 'eps', 'nonlinearity']
def __init__(self, num_features, eps=1e-5, nonlinearity=True):
super(EvoNorm2d, self).__init__()
@kashif
kashif / input_fn.py
Last active Mar 2, 2019
TensorFlow 1.x Estimator input pipeline function to read images organised in their class folders
View input_fn.py
def input_fn(file_pattern, labels,
image_size=(224,224),
shuffle=False,
batch_size=64,
num_epochs=None,
buffer_size=4096,
prefetch_buffer_size=None):
table = tf.contrib.lookup.index_table_from_tensor(mapping=tf.constant(labels))
num_classes = len(labels)
@kashif
kashif / acc_sgd.py
Created Mar 16, 2018
AccSGD optimizer for keras
View acc_sgd.py
class AccSGD(Optimizer):
"""AccSGD optimizer.
Arguments:
lr (float): learning rate
kappa (float, optional): ratio of long to short step (default: 1000)
xi (float, optional): statistical advantage parameter (default: 10)
smallConst (float, optional): any value <=1 (default: 0.7)
# References
@kashif
kashif / amsgrad.py
Last active May 13, 2019
Keras implementation of AMSGrad optimizer from "On the Convergence of Adam and Beyond" paper
View amsgrad.py
class AMSgrad(Optimizer):
"""AMSGrad optimizer.
Default parameters follow those provided in the Adam paper.
# Arguments
lr: float >= 0. Learning rate.
beta_1: float, 0 < beta < 1. Generally close to 1.
beta_2: float, 0 < beta < 1. Generally close to 1.
epsilon: float >= 0. Fuzz factor.
@kashif
kashif / fashion_mnist_cnn.py
Last active Nov 27, 2020
Fashion Mnist Benchmark
View fashion_mnist_cnn.py
'''Trains a simple convnet on the Zalando MNIST dataset.
Gets to 81.03% test accuracy after 30 epochs
(there is still a lot of margin for parameter tuning).
3 seconds per epoch on a GeForce GTX 980 GPU with CuDNN 5.
'''
from __future__ import print_function
import numpy as np
from mnist import MNIST
@kashif
kashif / es.py
Last active Jun 5, 2017
Initial implementation of Evolution Strategies
View es.py
import numpy as np
import gym
from gym.spaces import Discrete, Box
from gym.wrappers import Monitor
from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
# ================================================================
# Policies
View autocolorize.prototxt
name: "autocolorize"
input: "data"
input_dim: 1
input_dim: 1
input_dim: 514
input_dim: 514
layer {
name: "data"
type: "Input"
top: "data"
You can’t perform that action at this time.