Skip to content

Instantly share code, notes, and snippets.

View neilslater's full-sized avatar

Neil Slater neilslater

View GitHub Profile
@neilslater
neilslater / GTPtest.md
Created September 6, 2023 17:28
GPT self-assessment exploration.

One

System: You are a helpful assistant

User: Dave can dig a hole in 5 hours, Bob can dig a hole of the same size in 4 hours, Adam can dig a hole of the same size in 3 hours. How long would they take to dig the hole if they worked together?

Assistant: To solve this problem, we can find the rate at which each person can dig the hole by calculating the fraction of the hole they can dig in one hour.

Dave's rate ## 1 hole / 5 hours ## 1/5 hole per hour Bob's rate ## 1 hole / 4 hours ## 1/4 hole per hour

@neilslater
neilslater / example_dnn.py
Last active August 25, 2019 08:10
100% accuracy on example from AI Stack Exchange question
import numpy as np
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.optimizers import SGD
from keras.utils import to_categorical
def get_data():
X = np.array([[1,2], [1,12], [1,17], [9,33], [48,49], [48,50]])
@neilslater
neilslater / gist:28004397a544f97b2ff03d25d4ddae52
Last active February 11, 2021 12:31
MountainCar semi-gradient SARSA(0) - with neural network and experience replay
#improves the output of keras on Windows
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='3'
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
import logging
logging.getLogger("tensorflow").setLevel(logging.WARNING)
import numpy as np
import keras as K
@neilslater
neilslater / gist:48028d698ac7cef940b7cdb7e7ae91b4
Created July 8, 2017 07:37
Restoring scaling, convergence in 433 iterations. You can increase alpha again when scaled
# Define size of the layers, as well as the learning rate alpha and the max error
inputLayerSize = 2
hiddenLayerSize = 3
outputLayerSize = 1
alpha = 0.5
maxError = 0.001
# Import dependencies
import numpy
from sklearn import preprocessing
# Define size of the layers, as well as the learning rate alpha and the max error
inputLayerSize = 2
hiddenLayerSize = 3
outputLayerSize = 1
alpha = 0.01
maxError = 0.001
# Import dependencies
import numpy
from sklearn import preprocessing
@neilslater
neilslater / brix.py
Created August 9, 2016 07:58
Keras example image regression, extract texture height param
# -*- coding: utf-8 -*-
import numpy as np
import os
import cv2
import pandas as pd
from sklearn.cross_validation import train_test_split
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D
@neilslater
neilslater / games_dice_example.rb
Last active May 17, 2020 19:10
How to use GamesDice to produce stats for fixed size dice pool
# Related to: http://rpg.stackexchange.com/questions/37270/how-can-i-get-anydice-to-determine-these-odds
require 'games_dice'
die_types = [ 4, 6, 8, 10, 12, 20 ]
die_types.each_cons(2) do |type_lower, type_upper|
(0..6).each do |num_upper|
num_lower = 6 - num_upper
@neilslater
neilslater / gist:5476045
Last active December 16, 2015 18:09
Rough and ready spectrogram code
require 'narray'
require 'fftw3'
require 'raiff'
require 'rmagick'
# This class models audio power spectrum generation from audio sources (as .aiff files)
# An instance of this class represents a single audio clip and its spectrogram
class AudioSpectrum
# TODO: Over time, we want to improve on these crude hard-coded values, and either take them
# as params (e.g. number of windows, min/max frequency to store), or read from the audio file