Skip to content

Instantly share code, notes, and snippets.

View iganichev's full-sized avatar

Igor Ganichev iganichev

View GitHub Profile
@iganichev
iganichev / save_restore_new_layer.py
Last active April 23, 2022 21:10
Minimal example of saving/restoring a tensorflow model that has some additions done to it after it was saved
#!/usr/bin/env python
import sys
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
class Model(object):
def __init__(self, x, with_new_layer=False):
@iganichev
iganichev / lstm_state_carry_over.py
Last active March 3, 2019 16:09
Small example for carrying previous LSTM state into next training batch
#!/usr/bin/env python
""" This example trains an LSTM to predict the next number
in a sequence 0, 0, 1, 1, 0, 0, 1, 1, ...
Training is done on very short sequences of length 3.
Loss is computed on all but the last predicted value for simplicity.
When REMEMBER_STATE is True, the previous LSTM state is transfered
to the next training step and the network reaches almost zero error.
When REMEMBER STATE is False, the network has no way to predict the
#include <assert.h>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
bool next_perm(vector<int>& v) {