Skip to content

Instantly share code, notes, and snippets.

View hollance's full-sized avatar

Matthijs Hollemans hollance

View GitHub Profile
@hollance
hollance / workaround.markdown
Created October 9, 2020 09:59
Workaround for Xcode 12 problems with Core ML models

I ran into a problem with Xcode 12's Core ML compiler, and several people have emailed me about what appears to be the same issue.

The workaround is to use Xcode 11 to compile the Core ML model. This means you still need to have Xcode 11 installed (which is a good idea anyway).

What worked for me is the following...

From the Terminal, switch to the Xcode 11.7 installation (your path may be different):

sudo xcode-select -s /Applications/Xcode11.7.app/Contents/Developer/
@hollance
hollance / ARC.ipynb
Created September 8, 2020 13:25
ARC test
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
A few years after my stint in Japan, I ended up back in the United
States, hired by an AI software outfit to be their director of corporate
communications. Cool, I thought. That sounded important. I had no idea
what it meant. Only later did I discover I'd become their PR guy.
Bummer.
I was pretty naive back then, but I quickly figured out that public
relations was perceived by the press — the people I was supposed to be
talking to — as little more than thinly disguised hucksterism. I tried
playing the high-tech huckster role precisely once and came away from
@hollance
hollance / CoreML+Combine.swift
Created November 12, 2019 16:28
Using Core ML with Combine
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.
@hollance
hollance / convert_weights.py
Created October 7, 2017 20:43
SE-ResNet-50 in Keras
# Convert SE-ResNet-50 from Caffe to Keras
# Using the model from https://github.com/shicai/SENet-Caffe
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
hollance / Compressing-MobileNet.ipynb
Created September 26, 2017 12:47
Jupyter notebook for compressing MobileNet (work in progress)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hollance
hollance / Shaders.metal
Created July 19, 2017 11:54
Relu6 in 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)]],
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hollance
hollance / deconv.py
Created May 13, 2017 20:47
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
hollance / XOR.swift
Created January 11, 2017 18:05
Playing with BNNS (Swift version). The "hello world" of neural networks.
/*
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.