Skip to content

Instantly share code, notes, and snippets.

View davegreenwood's full-sized avatar

Dave Greenwood davegreenwood

  • University of East Anglia
View GitHub Profile
@DSA101
DSA101 / RNN.py
Last active December 6, 2017 06:52
Time series prediction with multiple sequences using RNN/LSTM (see https://groups.google.com/forum/#!topic/keras-users/9GsDwkSdqBg)
# Time series forecasting based on multiple time series, including the original one
# This script is based on the following examples and discussions:
# https://gist.github.com/lukovkin/1aefa4509e066690b892
# https://groups.google.com/forum/#!topic/keras-users/9GsDwkSdqBg
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import random
import theano
@scottwallacesh
scottwallacesh / RSA_encrypt_decrypt_strings_files_using_OpenSSL_and_RSA_SSH_keys
Created February 18, 2016 08:58
Encrypt and/or decrypt strings or files using OpenSSL and SSH RSA keys
# encrypt stdin
echo "secret" | openssl rsautl -encrypt -inkey ~/.ssh/id_rsa -out secret.enc
# encrypt file
openssl rsautl -encrypt -inkey ~/.ssh/id_rsa -in secret.txt -out secret.enc
# decrypt to stdout
openssl rsautl -decrypt -inkey ~/.ssh/id_rsa -in secret.enc
bl_info = {
"name": "FILL ME MO",
"author": "",
"version": (0, 1),
"blender": (2, 7, 6),
"category": "3D View"
}
import os
import bpy
@lukovkin
lukovkin / multi-ts-lstm.py
Last active November 25, 2022 16:23
Time series prediction with multiple sequences input - LSTM - 1
# Time Series Testing
import keras.callbacks
from keras.models import Sequential
from keras.layers.core import Dense, Activation, Dense, Dropout
from keras.layers.recurrent import LSTM
# Call back to capture losses
class LossHistory(keras.callbacks.Callback):
def on_train_begin(self, logs={}):
self.losses = []
@StuartGordonReid
StuartGordonReid / ApproximateEntropy.py
Last active April 7, 2024 11:19
Python implementation of the Approximate Entropy cryptographic test for randomness
def approximate_entropy(self, bin_data: str, pattern_length=10):
"""
Note that this description is taken from the NIST documentation [1]
[1] http://csrc.nist.gov/publications/nistpubs/800-22-rev1a/SP800-22rev1a.pdf
As with the Serial test of Section 2.11, the focus of this test is the frequency of all possible overlapping
m-bit patterns across the entire sequence. The purpose of the test is to compare the frequency of overlapping
blocks of two consecutive/adjacent lengths (m and m+1) against the expected result for a random sequence.
:param bin_data: a binary string
@Zulko
Zulko / zombie_france.py
Last active May 24, 2024 21:54
Zombie pandemic simulation in France
"""
Model of a Zombie outbreak in France, starting in Grenoble
This is a rewrite from this blog post by Max Berrgren:
http://maxberggren.github.io/2014/11/27/model-of-a-zombie-outbreak/
with a different country, a slightly different model, and different
libraries. The map of population density is taken from Wikimedia Commons
@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.
@lmullen
lmullen / Makefile
Last active May 30, 2024 09:34
PDF slides and handouts using Pandoc and Beamer
SLIDES := $(patsubst %.md,%.md.slides.pdf,$(wildcard *.md))
HANDOUTS := $(patsubst %.md,%.md.handout.pdf,$(wildcard *.md))
all : $(SLIDES) $(HANDOUTS)
%.md.slides.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -o $@
%.md.handout.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -V handout -o $@
#!/bin/zsh
#
# Highlight a given file and copy it as RTF.
#
# Simon Olofsson <[email protected]>
#
set -o errexit
set -o nounset
@erogol
erogol / cluster.py
Created December 13, 2013 15:46
clustering with theano
import numpy as np
import numpy
import theano
import theano.tensor as T
from theano import function, config, shared, sandbox
from theano import ProfileMode
from sklearn import cluster, datasets
import matplotlib.pyplot as plt
def rsom(data, cluster_num, alpha, epochs = -1, batch = 1, verbose = False):