Skip to content

Instantly share code, notes, and snippets.

@skeeet
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
let TOURNAMENT_SIZE = 5
let MAX_GENERATIONS_COUNT = 100
View pytorch-conv1d-rnn.py
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
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
skeeet / build.sh
Created Dec 7, 2017 — forked from graetzer/build.sh
PJSIP 2.6 iPhone iOS 9.0 build script
View build.sh
#!/bin/bash
echo "Building pjsip:"
# change this to whatever DEVPATH works
# if you get make errors, maybe redownload pjsip and try again
export DEVPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
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
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@skeeet
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
skeeet / DSSIM.py
Created Jun 3, 2017 — forked from Dref360/DSSIM.py
Difference of stuctural similarity using Tensorflow and keras. Works ONLY on tf >= 0.11
View DSSIM.py
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
skeeet / libjpeg.sh
Created May 20, 2017 — forked from eminarcissus/libjpeg.sh
Download & Compile Libjpeg for iOS (all architectures)
View libjpeg.sh
# 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 tar.bz of the libjpeg you want to build, shove it in the
# same directory as this script, and run "./libjpeg.sh". Grab a cuppa. And voila.
@skeeet
skeeet / residual_lstm_keras.py
Created May 5, 2017 — forked from bzamecnik/model_summary.txt
Residual LSTM in Keras
View residual_lstm_keras.py
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
skeeet / rnn_viz_keras.py
Created May 4, 2017 — forked from tokestermw/rnn_viz_keras.py
Recurrent Neural Network (RNN) visualizations using Keras.
View rnn_viz_keras.py
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