Skip to content

Instantly share code, notes, and snippets.

View falaktheoptimist's full-sized avatar

Falak falaktheoptimist

View GitHub Profile
@rpicatoste
rpicatoste / convert_to_inference_model.py
Last active October 28, 2022 09:40
Function to convert a Keras LSTM model trained as stateless to a stateful model expecting a single sample and time step as input to use in inference.
import json
from keras.models import model_from_json
def convert_to_inference_model(original_model):
original_model_json = original_model.to_json()
inference_model_dict = json.loads(original_model_json)
layers = inference_model_dict['config']
for layer in layers:
if 'stateful' in layer['config']:
@yaroslavvb
yaroslavvb / cpu_device_test.py
Created October 16, 2016 20:25
Run matmul on different CPU devices, plot timeline
import tensorflow as tf
from tensorflow.python.client import timeline
n = 1024
with tf.device("cpu:0"):
a1 = tf.ones((n, n))
a2 = tf.ones((n, n))
with tf.device("cpu:1"):
a3 = tf.matmul(a1, a2)
with tf.device("cpu:2"):
@troyane
troyane / SNER_preparer
Last active February 1, 2023 21:53
Script to prepare Stanford NER to work with your Python and NLTK
#!/bin/bash
mkdir my_project
cd my_project
echo " . . . Downloading file stanford-ner-2014-08-27.zip"
# NOTE: need to update link for further versions
wget http://nlp.stanford.edu/software/stanford-ner-2014-08-27.zip
echo " . . . Unpacking stanford-ner-2014-08-27.zip"