Skip to content

Instantly share code, notes, and snippets.

@dongso
dongso / example_trainer.cc
Created April 9, 2022 13:19 — forked from NobodyIsThere/example_trainer.cc
Load a TensorFlow graph in C++
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@dongso
dongso / timeseries_cnn.py
Created December 7, 2020 02:30 — 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
import os
import struct
import numpy as np
"""
Loosely inspired by http://abel.ee.ucla.edu/cvxopt/_downloads/mnist.py
which is GPL licensed.
"""
def read(dataset = "training", path = "."):
@dongso
dongso / Q-Table Learning-Clean.ipynb
Created November 5, 2019 12:50 — forked from awjuliani/Q-Table Learning-Clean.ipynb
Q-Table learning in OpenAI grid world.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dongso
dongso / deep_gambler.py
Created October 30, 2019 14:01 — forked from joannapurosto/deep_gambler.py
Q-learning tutorial part 3 and Deep Learning
from enums import *
import random
import tensorflow as tf
import numpy as np
class DeepGambler:
def __init__(self, learning_rate=0.1, discount=0.95, exploration_rate=1.0, iterations=10000):
self.learning_rate = learning_rate
self.discount = discount # How much we appreciate future reward over current
self.exploration_rate = 1.0 # Initial exploration rate
@dongso
dongso / DTW_python.py
Created June 6, 2019 11:35 — forked from bistaumanga/DTW_python.py
Dynamic Time warping implemented in python
'''Implementation and Demostration of Dynamic Time Warping
Requires : python 2.7.x, Numpy 1.7.1, Matplotlib, 1.2.1'''
from math import *
import numpy as np
import sys
def DTW(A, B, window = sys.maxint, d = lambda x,y: abs(x-y)):
# create the cost matrix
A, B = np.array(A), np.array(B)