main.py
def reload_graph(exp_dir):
    """
    Reload the computation graph and return handles to the required tensors
    for resuming training

    :param exp_dir: experiment directory
    :return: tuple of tensors
    """
    model_file = [f for f in os.listdir(exp_dir) if f.endswith('.meta')]
    if len(model_file)!=1:
        raise ValueError
    model_file = os.path.join(exp_dir,model_file[0])

    tf.train.import_meta_graph(model_file)
    graph = tf.get_default_graph()
    nodes = [node for node in graph.as_graph_def().node]

    def get_tensor(name):
        name = next(node.name for node in nodes if name == node.name)+':0'
        return graph.get_tensor_by_name(name)

    def get_op(name):
        name = next(node.name for node in nodes if node.name.endswith(name))
        return graph.get_operation_by_name(name)

    model_input = get_tensor('input')
    training_toggle = get_tensor('training_toggle')
    dropout_rate = get_tensor('dropout_rate')
    train_step = get_op('train_step')
    init_train = get_op('init_train')
    init_val = get_op('init_val')
    loss = get_tensor('loss')
    dni_loss = get_tensor('dni_loss')
    gru_output = get_tensor('gru_output')
    gru_h0 = get_tensor('gru_h0')
    output = get_tensor('output')

    return (model_input, training_toggle, dropout_rate, train_step,
            init_train, init_val, loss, dni_loss, gru_output, gru_h0, output)

    Reload the computation graph and return handles to the required tensors
    for resuming training

    :param exp_dir: experiment directory
    :return: tuple of tensors
    
Reload the computation graph and return handles to the required tensors
for resuming training
Reload the computation graph and return handles to the required tensors for resuming training
def reload_graph(exp_dir):
    model_file = [f for f in os.listdir(exp_dir) if f.endswith('.meta')]
    if len(model_file)!=1:
        raise ValueError
    model_file = os.path.join(exp_dir,model_file[0])
    tf.train.import_meta_graph(model_file)
    graph = tf.get_default_graph()
    nodes = [node for node in graph.as_graph_def().node]
    def get_tensor(name):
        name = next(node.name for node in nodes if name == node.name)+':0'
        return graph.get_tensor_by_name(name)
    def get_op(name):
        name = next(node.name for node in nodes if node.name.endswith(name))
        return graph.get_operation_by_name(name)
    model_input = get_tensor('input')
    training_toggle = get_tensor('training_toggle')
    dropout_rate = get_tensor('dropout_rate')
    train_step = get_op('train_step')
    init_train = get_op('init_train')
    init_val = get_op('init_val')
    loss = get_tensor('loss')
    dni_loss = get_tensor('dni_loss')
    gru_output = get_tensor('gru_output')
    gru_h0 = get_tensor('gru_h0')
    output = get_tensor('output')
    return (model_input, training_toggle, dropout_rate, train_step,
            init_train, init_val, loss, dni_loss, gru_output, gru_h0, output)
def reload_graph ( exp_dir ) : model_file = [ f for f in os . listdir ( exp_dir ) if f . endswith ( '.meta' ) ] if len ( model_file ) != 1 : raise ValueError model_file = os . path . join ( exp_dir , model_file [ 0 ] ) tf . train . import_meta_graph ( model_file ) graph = tf . get_default_graph ( ) nodes = [ node for node in graph . as_graph_def ( ) . node ] def get_tensor ( name ) : name = next ( node . name for node in nodes if name == node . name ) + ':0' return graph . get_tensor_by_name ( name ) def get_op ( name ) : name = next ( node . name for node in nodes if node . name . endswith ( name ) ) return graph . get_operation_by_name ( name ) model_input = get_tensor ( 'input' ) training_toggle = get_tensor ( 'training_toggle' ) dropout_rate = get_tensor ( 'dropout_rate' ) train_step = get_op ( 'train_step' ) init_train = get_op ( 'init_train' ) init_val = get_op ( 'init_val' ) loss = get_tensor ( 'loss' ) dni_loss = get_tensor ( 'dni_loss' ) gru_output = get_tensor ( 'gru_output' ) gru_h0 = get_tensor ( 'gru_h0' ) output = get_tensor ( 'output' ) return ( model_input , training_toggle , dropout_rate , train_step , init_train , init_val , loss , dni_loss , gru_output , gru_h0 , output )
Reload the computation graph and return handles to the required tensors
for resuming training
Reload the computation graph and return handles to the required tensors for resuming training
"""
    Reload the computation graph and return handles to the required tensors
    for resuming training

    :param exp_dir: experiment directory
    :return: tuple of tensors
    """
tuple of tensors
tuple of tensors
exp_dir
None