Skip to content

Instantly share code, notes, and snippets.

from keras import backend
from keras.backend import numpy_backend
import numpy as np
import tensorflow as tf
class NPTF(object):
def __getattr__(self, name):
if name in dir(numpy_backend) and name in dir(backend):
@bpierce1
bpierce1 / sftp.json
Created September 10, 2018 20:22
vscode sftp settings
// use value of $SSH_AUTH_SOCK for "agent"
{
"host": "my-ip.com",
"username": "bpierce",
"password": null,
"privateKeyPath": "/path/to/.ssh/id_rsa",
"uploadOnSave": true,
"protocol": "sftp",
"remotePath": "/remote/path/to/repo",
"agent": "/private/tmp/com.apple.launchd.Hp4qarj3Eb/Listeners"
@nvictus
nvictus / runlength.py
Last active March 25, 2025 20:47
NumPy run-length encoding / decoding
"""Run Length Encoding utilities for NumPy arrays.
Authors
-------
- Nezar Abdennur
- Anton Goloborodko
"""
from __future__ import division, print_function
import numpy as np
@yrevar
yrevar / imagenet1000_clsidx_to_labels.txt
Last active June 4, 2025 02:37
text: imagenet 1000 class idx to human readable labels (Fox, E., & Guestrin, C. (n.d.). Coursera Machine Learning Specialization.)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
@welch
welch / installing-opencv-2.4.5-macosx-10.8.4-anaconda-1.6.0
Created September 6, 2013 19:17
How to to build OpenCV 2.4.5 from the distribution tarball using cmake, on Mac OSX 10.8.4, linked to an anaconda installation.
It is a rite of passage to post one's successful build instructions for OpenCV on a Mac
after you've tried all the other conflicting instructions out there and still failed.
brew failed for me (was this because I could never get a happy brew doctor situation?
I'll never know). macports? nope. build-from-source recipes? I didn't find one that
worked for me.
Here's what did work to build OpenCV 2.4.5 from the distribution tarball using cmake,
on Mac OSX 10.8.4, linked to an anaconda installation rather than the system python.
It is a mashup of various bits of advice out there. If you're already comfortable with
build/install from source, all you need to read is the cmake invocation in step 3 and