This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from subprocess import check_call | |
def post_save(model, os_path, contents_manager): | |
"""post-save hook for converting notebooks to .py and .html files.""" | |
if model['type'] != 'notebook': | |
return # only do this for notebooks | |
d, fname = os.path.split(os_path) | |
check_call(['jupyter', 'nbconvert', '--to', 'script', fname], cwd=d) | |
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# testing variable order init | |
import tensorflow as tf | |
def initialize_all_variables(sess=None): | |
"""Initializes all uninitialized variables in correct order. Initializers | |
are only run for uninitialized variables, so it's safe to run this multiple | |
times. | |
Args: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySaver(tf.train.Saver): | |
def __init__(self, var_list, extra_vars=None, extra_chkpt_file=None, **kwargs): | |
super().__init__(var_list=var_list, **kwargs) | |
self.extra_chkpt_file = extra_chkpt_file | |
self.extra_saver = tf.train.Saver(var_list=extra_vars) | |
def restore(self, sess, save_path): | |
super().restore(sess, save_path) | |
self.extra_saver.restore(sess, self.extra_chkpt_file) | |