Skip to content

Instantly share code, notes, and snippets.

@akatumba
akatumba / sgdr.py
Created June 30, 2018 11:44 — forked from jeremyjordan/sgdr.py
Keras Callback for implementing Stochastic Gradient Descent with Restarts
from keras.callbacks import Callback
import keras.backend as K
import numpy as np
class SGDRScheduler(Callback):
'''Cosine annealing learning rate scheduler with periodic restarts.
# Usage
```python
schedule = SGDRScheduler(min_lr=1e-5,
@akatumba
akatumba / lamp.sh
Created March 14, 2018 09:39 — forked from aamnah/lamp.sh
Bash script to install Apache, MySQL and PHP as well as PHPMyAdmin and some tweaks. For Debian and Ubuntu. To run, copy the script to the server and run ``bash lamp.sh``
#!/bin/sh
#######################################
# Bash script to install an AMP stack and PHPMyAdmin plus tweaks. For Debian based systems.
# Written by @AamnahAkram from http://aamnah.com
# In case of any errors (e.g. MySQL) just re-run the script. Nothing will be re-installed except for the packages with errors.
#######################################
#COLORS
@akatumba
akatumba / bitbucket-pipelines.yml
Created February 13, 2018 14:12 — forked from adujardin/bitbucket-pipelines.yml
Bitbucket pipeline file for latex document (including bibtex and upload to dropbox)
# SETTING UP :
# Generate an application token for your dropbox account and set it as environment variable named "DROPBOX_TOKEN"
# - https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/
# - https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
# Edit TEX_FILE (see below) according to the main tex file name
image: fermiumlabs/latex-docker:latest
pipelines:
custom: # Manually only
@akatumba
akatumba / install.sh
Created November 29, 2017 21:23
VPS install bash script for Ubuntu 16.04
# =================== YOUR DATA ========================
SERVER_NAME="some-server-name"
SERVER_IP="111.111.11.11"
USER="someuser"
SUDO_PASSWORD="secret-password-one"
MYSQL_ROOT_PASSWORD="secret-password-two"
@akatumba
akatumba / min-char-rnn.py
Created January 21, 2017 16:20 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
#! /usr/bin/python
#
# Author: Gaute Hope (gaute.hope@nersc.no) / 2015
#
# based on example from matlab sinc function and
# interpolate.m by H. Hobæk (1994).
#
# this implementation is similar to the matlab sinc-example, but
# calculates the values sequentially and not as a single matrix
# matrix operation for all the values.
@akatumba
akatumba / pyspark
Last active August 29, 2015 14:18
pyspark LogisticRegressionWithSGD
from pyspark.mllib.classification import LogisticRegressionWithSGD
from pyspark.mllib.regression import LabeledPoint
from numpy import array #not used
#use sample data provided in the mllib installation
data = sc.textFile('data/mllib/sample_svm_data.txt')
#convert the data into the format expected by the regression model trainer
parsedData = data.map(lambda line: LabeledPoint(line.split(' ')[0], line.split(' ')[1:]))