Skip to content

Instantly share code, notes, and snippets.

skeeet / GeneticAlgorithm.swift
Created Apr 9, 2018 — forked from tombaranowicz/GeneticAlgorithm.swift
Simple Starter for experiments with Genetic Algorithms in Swift
View GeneticAlgorithm.swift
//: Simple Genetic Algorithm Starter in Swift 3
import UIKit
import Foundation
let AVAILABLE_GENES:[Int] = Array(1...100)
let DNA_LENGTH = 6
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers=1):
super(RNN, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
skeeet / neural.c
Created Jan 9, 2018 — forked from hollance/neural.c
Playing with BNNS on macOS 10.12. The "hello world" of neural networks.
View neural.c
The "hello world" of neural networks: a simple 3-layer feed-forward
network that implements an XOR logic gate.
The first layer is the input layer. It has two neurons a and b, which
are the two inputs to the XOR gate.
The middle layer is the hidden layer. This has two neurons h1, h2 that
will learn what it means to be an XOR gate.
skeeet /
Created Dec 7, 2017 — forked from graetzer/
PJSIP 2.6 iPhone iOS 9.0 build script
echo "Building pjsip:"
# change this to whatever DEVPATH works
# if you get make errors, maybe redownload pjsip and try again
export DEVPATH=/Applications/
MIN_IOS="-miphoneos-version-min=9.0" ARCH="-arch i386" CFLAGS="-O2 -m32 -mios-simulator-version-min=9.0 -fembed-bitcode" LDFLAGS="-O2 -m32 -mios-simulator-version-min=9.0 -fembed-bitcode" ./configure-iphone
View gist:f7aa7b293dcf70c950d190bdbc830003
ACTION = build
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
skeeet / Makefile
Created Aug 9, 2017 — forked from figgis/Makefile
ffmpeg qp values
View Makefile
# use pkg-config for getting CFLAGS and LDLIBS
FFMPEG_LIBS= libavdevice \
libavformat \
libavfilter \
libavcodec \
libswresample \
libswscale \
libavutil \
CFLAGS += -Wall -g
skeeet /
Created Jun 3, 2017 — forked from Dref360/
Difference of stuctural similarity using Tensorflow and keras. Works ONLY on tf >= 0.11
import keras.backend as K
import tensorflow as tf
class Model:
def __init__(self,batch_size):
self.batch_size = batch_size
def loss_DSSIS_tf11(self, y_true, y_pred):
"""Need tf0.11rc to work"""
y_true = tf.reshape(y_true, [self.batch_size] + get_shape(y_pred)[1:])
y_pred = tf.reshape(y_pred, [self.batch_size] + get_shape(y_pred)[1:])
skeeet /
Created May 20, 2017 — forked from eminarcissus/
Download & Compile Libjpeg for iOS (all architectures)
# Builds a Libjpeg framework for the iPhone and the iPhone Simulator.
# Creates a set of universal libraries that can be used on an iPhone and in the
# iPhone simulator. Then creates a pseudo-framework to make using libjpeg in Xcode
# less painful.
# To configure the script, define:
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 8.1)
# Then go get the source of the libjpeg you want to build, shove it in the
# same directory as this script, and run "./". Grab a cuppa. And voila.
skeeet /
Created May 5, 2017 — forked from bzamecnik/model_summary.txt
Residual LSTM in Keras
def make_residual_lstm_layers(input, rnn_depth, rnn_dropout):
The intermediate LSTM layers return sequences, while the last returns a single element.
The input is also a sequence. In order to match the shape of input and output of the LSTM
to sum them we can do it only for all layers but the last.
for i in range(rnn_depth):
return_sequences = i < rnn_depth - 1
x_rnn = LSTM(rnn_width, dropout_W=rnn_dropout, dropout_U=rnn_dropout, return_sequences=return_sequences)(input)
if return_sequences:
skeeet /
Created May 4, 2017 — forked from tokestermw/
Recurrent Neural Network (RNN) visualizations using Keras.
from __future__ import print_function
from keras import backend as K
from keras.engine import Input, Model, InputSpec
from keras.layers import Dense, Activation, Dropout, Lambda
from keras.layers import Embedding, LSTM
from keras.optimizers import Adam
from keras.preprocessing import sequence
from keras.utils.data_utils import get_file
from keras.datasets import imdb