Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Working from 🛰

Harry Moreno morenoh149

💭
Working from 🛰
View GitHub Profile
@morenoh149
morenoh149 / save-model-to-sagemaker.py
Created Feb 12, 2019
Tensorflow serve on Sagemaker
View save-model-to-sagemaker.py
def export_h5_to_pb(path_to_h5, export_path):
# Set the learning phase to Test since the model is already trained.
K.set_learning_phase(0)
# Load the Keras model
keras_model = load_model(path_to_h5)
# Build the Protocol Buffer SavedModel at 'export_path'
builder = saved_model_builder.SavedModelBuilder(export_path)
@morenoh149
morenoh149 / sol.py
Created Dec 5, 2018
Advent of Code 2018 Day 4 solution
View sol.py
import re
import pprint
pp = pprint.PrettyPrinter(indent=2)
def Input():
filename = './input.txt'
return open(filename)
lines = Input().read().split('\n')
@morenoh149
morenoh149 / postgis-geojson-liaison.js
Created Nov 9, 2018 — forked from DesignByOnyx/postgis-geojson-liaison.js
Helpful utility for converting postgis data into GeoJSON as it comes out of the db, and vice versa.
View postgis-geojson-liaison.js
var wkx = require('wkx')
var pg = require('pg')
var pgUtil = require('pg/lib/utils')
const geoParser = {
init(knex){
// 1. Convert postgis data coming out of the db into geoJSON
// Every postgres installation will have different oids for postgis geo types.
knex
.raw('SELECT oid, typname AS name FROM pg_type WHERE typname IN (\'geography\', \'geometry\');')
View fetch_parallel.js
const getInvite = fetch(
`${apiHost}/invite/?event=${event_id}&user=${userId}`
);
const getHost = fetch(`${apiHost}/user/${event.fields.host}/`);
Promise.all([getInvite, getHost, delayPromise(1000)()])
.then(values => {
values.pop(); // drop delayPromise's return value (undefined)
return values.map(v => v.json());
})
View error.py
import tensorflow as tf
from keras import backend as K
from tensorflow.python.saved_model import builder as saved_model_builder
from tensorflow.python.saved_model import tag_constants, signature_constants
from tensorflow.python.saved_model.signature_def_utils_impl import predict_signature_def
builder = saved_model_builder.SavedModelBuilder('vgg16_no_augmentation_export')
signature = predict_signature_def(inputs={'input': parallel_model.inputs[0]},
outputs={'income': parallel_model.outputs[0]})
View error.sh
---------------------------------------------------------------------------
MemoryError Traceback (most recent call last)
<ipython-input-22-567222df1eb0> in <module>()
----> 1 x_train = vectorize_sequences(train_data)
2 x_test = vectorize_sequences(test_data)
<ipython-input-21-5d7c33381575> in vectorize_sequences(sequences, dimension)
2 # are a 1 in the tensor, 0 otherwise
3 def vectorize_sequences(sequences, dimension=10000):
----> 4 results = np.zeros((len(sequences), dimension))
@morenoh149
morenoh149 / Nbutton.js
Last active Jul 14, 2018
React Native Platform specific button
View Nbutton.js
import React from "react";
import { Platform, TouchableNativeFeedback, TouchableOpacity, View } from "react-native";
const Colors = {
androidRippleDark: "#ccc"
};
const styles = {
style: {}
};
@morenoh149
morenoh149 / min-char-rnn.py
Created Jul 7, 2018 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
View min-char-rnn.py
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
View error.sh
$ docker build -t gcr.io/foo/polls .
Sending build context to Docker daemon 1.12MB
Step 1/7 : FROM gcr.io/google_appengine/python
latest: Pulling from google_appengine/python
1d47b358304c: Pull complete
c6cf9be4ad08: Pull complete
3c2cba919283: Pull complete
b5267a7c948d: Pull complete
327bc3d676fa: Pull complete
7084178c9da9: Pull complete
View .kube_config.yaml
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: foo
server: https://bar
name: baz
contexts:
- context:
cluster: baz
user: baz