Ejemplo n.º 1
0
    def examples(self, data_generator, num_examples=5):
        """
        Prints some examples during training
        Args:
            data_generator:

        """
        assert self.symbols

        x, y = data_generator.next_batch(validation=True)

        # input_strings = decode_output_sequences(x, symbols=SYMBOLS)
        target_strings = decode_output_sequences(y, symbols=self.symbols)

        model_output = self.predict(x)
        pred_strings = decode_output_sequences(model_output, symbols=self.symbols)

        print(target_strings[:num_examples])
        print(pred_strings[:num_examples])
logging = tf.logging

flags.DEFINE_string(
    "model", "small",
    "A type of model. Possible options are: small, medium, large, zoneout.")
flags.DEFINE_string("data_path", None, "data_path")
FLAGS = flags.FLAGS

from program_generator import ProgramGenerator, SYMBOLS, SYMBOL_TO_IDX, INPUT_SEQ_LEN, OUTPUT_SEQ_LEN

program_generator = ProgramGenerator(batch_size=10,
                                     program_length=1,
                                     num_len=2)
x, y = program_generator.next_batch()

input_strings = decode_output_sequences(x, symbols=SYMBOLS)
target_strings = decode_output_sequences(y, symbols=SYMBOLS)

print(" Inputs:", input_strings)
print("Targets:", target_strings)
session.close()
tf.reset_default_graph()
session = tf.InteractiveSession()

hidden_units = 320
num_layers = 2
training_batch_size = 128
num_symbols = len(SYMBOL_TO_IDX)

program_model = Seq2SeqProgramModel(session=session,
                                    hidden_units=hidden_units,
Ejemplo n.º 3
0
num_layers = 2
training_batch_size = 32
z_prob_cells = 0.05
z_prob_states = 0
num_symbols = len(SYMBOL_TO_IDX)
DEFAULT_LEARNING_RATE = 0.01
print('zoneout cells'+str(z_prob_cells)+'states'+str(z_prob_states))

#################
# DATA
#################

addition_generator = AdditionGenerator(batch_size=3)
x, y = addition_generator.next_batch()

input_strings = decode_output_sequences(x, symbols=SYMBOLS)
target_strings = decode_output_sequences(y, symbols=SYMBOLS)

print(" Inputs:", input_strings)
print("Targets:", target_strings)
session.close()
tf.reset_default_graph()
session = tf.InteractiveSession()

#################
# MODEL
#################

# Wrapper for the TF RNN cell
# For an LSTM, the 'cell' is a tuple containing state and cell
# We use TF's dropout to implement zoneout