Пример #1
0
 def get_config(config_size):
     config_size = config_size.lower()
     if config_size == 'small':
         return c.SmallConfig()
     elif config_size == 'medium':
         return c.MediumConfig()
     elif config_size == 'large':
         return c.LargeConfig()
     else:
         raise ValueError('Unknown config size {} (small, medium, large)'.format(config_size))
Пример #2
0
def DataTests():
    model_config = config.MediumConfig()
    train_data = PTB_DATA()
    train_data.load_data(config.TRAIN_FILENAME, model_config.batch_size)
    total_batch = int((train_data.batch_len - 1)/model_config.num_steps)
    shape = (model_config.batch_size, model_config.num_steps)
    for epoch in range(2):
        for batch in range(total_batch):
            batch_X, batch_Y = train_data.generate_batch(model_config.batch_size, model_config.num_steps, batch)
            print("batch:", batch)
            assert batch_X.shape == shape
            assert batch_Y.shape == shape
Пример #3
0
@author: rahul.ghosh
"""

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
import data
import model
import config
import tensorflow as tf


if __name__ == "__main__":
    with tf.Graph().as_default():
        # LOAD CONFIG
        model_config = config.MediumConfig()
        eval_config = config.MediumConfig()
        gen_config = config.SmallGenConfig()
        eval_config.batch_size = 1
        eval_config.num_steps = 1
        # READ DATA
        train_data = data.PTB_DATA()
        train_data.load_data(config.TRAIN_FILENAME, model_config.batch_size)
#        valid_data = data.PTB_DATA()
#        valid_data.load_data(config.VALIDATION_FILENAME, model_config.batch_size)
        test_data = data.PTB_DATA()
        test_data.load_data(config.TEST_FILENAME, eval_config.batch_size)
        # BUILD MODEL
        initializer = tf.random_uniform_initializer(-model_config.init_scale,
                                                    model_config.init_scale)
        with tf.name_scope("Train"):