python - Can we feed a value without defining tf.placeholder? -


here code https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/models/rnn/ptb/ptb_word_lm.py,i wonder why can feed model by:

cost, state, _ = session.run([m.cost, m.final_state, eval_op],                               {m.input_data: x,                                m.targets: y,                                m.initial_state: state}) 

because initial_state isn't tf.placeholder,so how can feed it?

in code, defines class. , defines self._initial_state = cell.zero_state(batch_size, data_type()), state = self._initial_state, , (cell_output, state) = cell(inputs[:, time_step, :], state). after that, self._final_state = state. what's more, defines function in class:

@property def final_state(self): return self._final_state

and here comes

state = m.initial_state.eval() cost, state, _ = session.run([m.cost, m.final_state, eval_op],                              {m.input_data: x,                               m.targets: y,                               m.initial_state: state}) 

and have ran code locally, quite have difference without state in feeddict.

can help?

because initial_state isn't tf.placeholder,so how can feed it?

placeholder tensorflow tensor; can feed tensor using feed_dict mechanism,

and have ran code locally, quite have difference without state in feed_dict.

here if don't feed learned state previous batch, state initialized 0 next batch, hence there degradation of results.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -