Loading caption-lib/lstm/Readers/basic_text_reader.py +1 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ def read_input(filename): ''' Create sequences and save them example: [['You', 'can', 'see', 'a', 'cat', 'on', 'a', 'table', '<EOS>'], ['You', 'can', 'see', 'a', 'dog', 'on', 'a', 'table', '<EOS>']] ''' def create_sequences(filename): return True Loading caption-lib/lstm/configuration.py +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class default_trainer(object): input_embedding_size = 20 # length of the charater encoder_hidden_units = 20 decoder_hidden_units = encoder_hidden_units * 2 max_batches = 300 max_batches = 2 batches_in_epoch = 10 batch_size = 10 PAD = 0 Loading caption-lib/lstm/lstm_train.py +7 −5 Original line number Diff line number Diff line Loading @@ -72,8 +72,9 @@ def loop_fn(time, previous_output, previous_state, previous_loop_state): else: return loop_fn_transition(time, previous_output, previous_state, previous_loop_state) def sequence_feed(batches): batch = next(batches) # batches ist bei uns ein Satz [[You, can, see, a, cat, on, a, table, <EOS>], [You, can, see, a, dog, on, a, table, <EOS>]] def sequence_feed(): batch = next(g) # batches ist bei uns ein Satz [[You, can, see, a, cat, on, a, table, <EOS>], [You, can, see, a, dog, on, a, table, <EOS>]] # eine batch [You, can, see, a, cat, on, a, table, <EOS>] encoder_inputs_, encoder_input_lengths_ = helper.batch(batch) decoder_targets_, _ = helper.batch( Loading Loading @@ -199,18 +200,19 @@ train_op = tf.train.AdamOptimizer().minimize(loss) sess.run(tf.global_variables_initializer()) loss_track = [] batches = [['You', 'can', 'see', 'a', 'cat', 'on', 'a', 'table', '<EOS>'], ['You', 'can', 'see', 'a', 'dog', 'on', 'a', 'table', '<EOS>']] g = (iterator for iterator in batches) # training the real deal executes here: try: for current_batch_index in range(config.trainer.max_batches): # TODO care for max lenght and size of captions """ encoder_inputs: encoder_inputs_, encoder_inputs_length: encoder_input_lengths_, decoder_targets: decoder_targets_, """ fd = sequence_feed() _, loss_current = sess.run(([train_op], loss), fd) loss_track.append(loss_current) Loading Loading
caption-lib/lstm/Readers/basic_text_reader.py +1 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ def read_input(filename): ''' Create sequences and save them example: [['You', 'can', 'see', 'a', 'cat', 'on', 'a', 'table', '<EOS>'], ['You', 'can', 'see', 'a', 'dog', 'on', 'a', 'table', '<EOS>']] ''' def create_sequences(filename): return True Loading
caption-lib/lstm/configuration.py +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ class default_trainer(object): input_embedding_size = 20 # length of the charater encoder_hidden_units = 20 decoder_hidden_units = encoder_hidden_units * 2 max_batches = 300 max_batches = 2 batches_in_epoch = 10 batch_size = 10 PAD = 0 Loading
caption-lib/lstm/lstm_train.py +7 −5 Original line number Diff line number Diff line Loading @@ -72,8 +72,9 @@ def loop_fn(time, previous_output, previous_state, previous_loop_state): else: return loop_fn_transition(time, previous_output, previous_state, previous_loop_state) def sequence_feed(batches): batch = next(batches) # batches ist bei uns ein Satz [[You, can, see, a, cat, on, a, table, <EOS>], [You, can, see, a, dog, on, a, table, <EOS>]] def sequence_feed(): batch = next(g) # batches ist bei uns ein Satz [[You, can, see, a, cat, on, a, table, <EOS>], [You, can, see, a, dog, on, a, table, <EOS>]] # eine batch [You, can, see, a, cat, on, a, table, <EOS>] encoder_inputs_, encoder_input_lengths_ = helper.batch(batch) decoder_targets_, _ = helper.batch( Loading Loading @@ -199,18 +200,19 @@ train_op = tf.train.AdamOptimizer().minimize(loss) sess.run(tf.global_variables_initializer()) loss_track = [] batches = [['You', 'can', 'see', 'a', 'cat', 'on', 'a', 'table', '<EOS>'], ['You', 'can', 'see', 'a', 'dog', 'on', 'a', 'table', '<EOS>']] g = (iterator for iterator in batches) # training the real deal executes here: try: for current_batch_index in range(config.trainer.max_batches): # TODO care for max lenght and size of captions """ encoder_inputs: encoder_inputs_, encoder_inputs_length: encoder_input_lengths_, decoder_targets: decoder_targets_, """ fd = sequence_feed() _, loss_current = sess.run(([train_op], loss), fd) loss_track.append(loss_current) Loading