Skip to content

Instantly share code, notes, and snippets.

View vgoklani's full-sized avatar

Vishal Goklani vgoklani

View GitHub Profile
@vgoklani
vgoklani / random-search-example.py
Created March 22, 2018 18:24 — forked from jdherman/random-search-example.py
example of pure random search in python
from random import random
# function to optimize: takes in a list of decision variables, returns an objective value
# this is the Rosenbrock function: http://en.wikipedia.org/wiki/Rosenbrock_function
# the global minimum is located at x = (1,1) where f(x) = 0
def my_function(x):
return (1-x[0])**2 + 100*(x[1] - x[0]**2)**2
# function to perform (a very crude, stupid) optimization
# bounds = lower and upper bounds for each decision variable (2D list)
from __future__ import print_function
from itertools import starmap
import tensorflow as tf
import random
from tensorflow.python.ops import rnn
import math
flags = tf.flags
@vgoklani
vgoklani / timeseries_cnn.py
Created January 11, 2018 06:52 — forked from jkleint/timeseries_cnn.py
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
#!/usr/bin/env python
"""
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
"""
from __future__ import print_function, division
import numpy as np
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten
from keras.models import Sequential
@vgoklani
vgoklani / timeseries_cnn.py
Created January 11, 2018 06:52 — forked from jkleint/timeseries_cnn.py
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
#!/usr/bin/env python
"""
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
"""
from __future__ import print_function, division
import numpy as np
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten
from keras.models import Sequential
@vgoklani
vgoklani / simdkalman-kaggle-example.ipynb
Created December 9, 2017 16:53 — forked from oseiskar/simdkalman-kaggle-example.ipynb
simdkalman example: Kaggle Web Traffic Time Series Forecasting
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / TFQueueKeras.py
Created October 22, 2017 03:42 — forked from Dref360/TFQueueKeras.py
An example of using keras with tf queues, this handle BatchNorm
import operator
import threading
from functools import reduce
import keras
import keras.backend as K
from keras.engine import Model
import numpy as np
import tensorflow as tf
import time
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
import numpy as np
import torch.optim as optim
from torch.autograd import Variable
@vgoklani
vgoklani / node-cluster-messaging.js
Created August 9, 2017 23:21 — forked from jpoehls/node-cluster-messaging.js
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@vgoklani
vgoklani / stream.py
Created July 1, 2017 22:05 — forked from messa/stream.py
Twitter Streaming API example
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
import oauth2 # https://raw.github.com/brosner/python-oauth2/master/oauth2/__init__.py
from pprint import pprint
import urllib2
stream_url = "https://stream.twitter.com/1/statuses/filter.json"
@vgoklani
vgoklani / classifier_from_little_data_script_3.py
Created June 30, 2017 03:55 — forked from fchollet/classifier_from_little_data_script_3.py
Fine-tuning a Keras model. Updated to the Keras 2.0 API.
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats