Skip to content

Instantly share code, notes, and snippets.

View prabindh's full-sized avatar
💭
I may be slow to respond.

Prabindh Sundareson prabindh

💭
I may be slow to respond.
View GitHub Profile
#!/bin/bash
MULT="100"
NIGHTLIES=14
STABLE=13
LOWEST=11
RAPIDS_VERSION="0.$STABLE"
RAPIDS_RESULT=$STABLE
@prabindh
prabindh / pc-server.py
Created April 10, 2020 02:20
Server side Py application
from http.server import HTTPServer, BaseHTTPRequestHandler
from io import BytesIO
import os
import json
from pyautogui import press
def do_POST(self):
press('space')
# Standard respnse sequence headers fill here
@prabindh
prabindh / main.py
Last active April 10, 2020 02:26
Station-side Python code
import network
import urequests
import ujson
import machine
import time
def do_post(url, data):
headers = {'Content-Type': 'application/json'}
// Prabindh Sundareson 2020
// Age of the lockdown
#include "pch.h" // include #include "httplib.h" in this file
#include <iostream>
static httplib::Server svr;
void pressSpace()
{
@prabindh
prabindh / gitdiff.diff
Created May 28, 2019 13:44
darknet master and alexey fork diff yolov3
$ diff ~/Downloads/yolov3.cfg-master.txt ~/Downloads/yolov3.cfg-alexeyab.txt
3,4c3,4
< # batch=1
< # subdivisions=1
---
> batch=1
> subdivisions=1
6,9c6,9
< batch=64
< subdivisions=16
@prabindh
prabindh / spikechecker.py
Created May 17, 2019 03:56
spike checker
# conv1d for timeseries spike
model = models.Sequential()
model.add(layers.Conv1D(filters = 1,
kernel_size = 10,
activation = 'relu',
input_shape=(timesteps,1)))
model.add(layers.GlobalMaxPooling1D())
model.add(layers.Flatten())
model.add(layers.Dense(1, activation = 'sigmoid'))
@prabindh
prabindh / conv2dtricks.py
Created May 14, 2019 05:11
numpy conv2d tricks
import numpy as np
from numpy.lib.stride_tricks import as_strided
import tensorflow as tf
import time
def conv2dTrickster(a, b):
a = as_strided(a,(len(a),a.shape[1]-len(b)+1,a.shape[2]-b.shape[1]+1,len(b),b.shape[1],a.shape[3]),a.strides[:3]+a.strides[1:])
return np.einsum('abcijk,ijkd', a, b[::-1,::-1])
def conv2dSimple(image, filter):
from keras.datasets import mnist
from keras.layers import Dense, Input, concatenate,subtract, Lambda
from keras.losses import binary_crossentropy
from keras.optimizers import SGD
(train_x, train_y), (test_x, test_y) = mnist.load_data()
train_x = (train_x / 255.0).reshape(-1, 28*28)
test_x = (test_x / 255.0).reshape(-1, 28*28)
inp1 = Input(shape=(28*28,))
CuDNNGRU stateful implementation, TensorFlow backend
Layers: (300,80,150) -- (encoder, latent, decoder) -- (selu, tanh, tanh)
return_sequences=True for all layers
GaussianNoise + Dropout at (=after) input, AlphaDropout at encoder, Dropout at latent
BatchNormalization between encoder and latent, latent and decoder
Output: TimeDistributed(Dense(units=input_dim, activation='linear'))
batch_size=25, timesteps=400, input_dim=16 - 25 separate, 10-min sequences fed 400 timesteps (=1 sec) at a time (as 10*60=600 'windows' in parallel, non-shuffled)
reset_states() applied before testing on new x25 10-min sequences
model.fit, or train_on_batch for training
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
def normalize_angles(phases):
phases = phases + np.pi
phases /= (2 * np.pi)
return phases
def build_fourier_mnist():