Skip to content

Instantly share code, notes, and snippets.

Matthijs Hollemans hollance

View GitHub Profile
hollance / CoreML+Combine.swift
Created Nov 12, 2019
Using Core ML with Combine
View CoreML+Combine.swift
import CoreML
import Combine
extension Publisher where Self.Output: MLFeatureProvider {
Operator that lets you run a Core ML model as part of a Combine chain.
It accepts an MLFeatureProvider object as input, and, if all goes well,
returns another MLFeatureProvider with the model outputs.
# Convert SE-ResNet-50 from Caffe to Keras
# Using the model from
import os
import numpy as np
# The caffe module needs to be on the Python path; we'll add it here explicitly.
import sys
caffe_root = "/path/to/caffe"
sys.path.insert(0, caffe_root + "python")
hollance / Compressing-MobileNet.ipynb
Created Sep 26, 2017
Jupyter notebook for compressing MobileNet (work in progress)
View Compressing-MobileNet.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Shaders.metal
#include <metal_stdlib>
using namespace metal;
struct Relu6Params {
float a;
kernel void relu6(
texture2d_array<half, access::read> inTexture [[texture(0)]],
texture2d_array<half, access::write> outTexture [[texture(1)]],
View Sketch.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
hollance /
Created May 13, 2017
Playing with "deconvolution"
import numpy as np
i = np.array(list(range(1, 50)), dtype=np.float).reshape((7, 7))
k = np.array(list(range(1, 10)), dtype=np.float).reshape((3, 3))
print("Input:"); print(i)
print("Kernel:"); print(k)
# Forward convolution. We need to pad the input so that we can read from
# its borders. (Not doing stride etc here.)
hollance / XOR.swift
Created Jan 11, 2017
Playing with BNNS (Swift version). The "hello world" of neural networks.
View XOR.swift
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.
hollance / recursive-descent.swift
Created Dec 28, 2016
Simple recursive descent parser
View recursive-descent.swift
import Cocoa
let input = "15,7, 3 ,, [1,2,[3, 4, 5], 6],8"
//let input = "5,7,[1]"
var index = input.characters.startIndex
var lookahead = input[index]
var done = false
func eat() {
hollance / eliza.swift
Last active Jul 5, 2020
The classic ELIZA chat bot in Swift.
View eliza.swift
Joseph Weizenbaum's classic ELIZA chat bot in Swift.
Based on the IBM PC BASIC program from CREATIVE COMPUTING by Patricia
Danielson and Paul Hashfield, and the Java adaptation by Jesper Juul.
Run this script from Terminal:
$ swift eliza.swift
Press Ctrl-C or Ctrl-D to quit. (Or type "shut up".)
hollance / ZeroGravity.asm
Created Nov 23, 2016
Zero Gravity source code (Amiga 1200)
View ZeroGravity.asm
; *****************************************************************************
; $VER: ZeroGravity Source 1.0 (C) 1997 Matthijs Hollemans
; *****************************************************************************
; This is the full source code to Zero Gravity. I used the very cool ASM-One
; V1.29 assembler from T.F.A. but that doesn't matter anyway because you won't
; be able to reassemble this without the required binary includes...
You can’t perform that action at this time.