def export_ops(self, name): """Exports ops to collections.""" self._name = name self._exported_ops = {} ops = {} ops[util.with_prefix(self._name, 'clfs_padd')] = self._padding ops[util.with_prefix(self._name, 'last_step')] = self._last_step for key, preds in self._predictions.items(): ops[util.with_prefix(self._name, key)] = preds self._exported_ops.update({'predictions': [f'{self._name}/{k}' for k in self._predictions]}) for key, loss in self._losses.items(): ops[util.with_prefix(self._name, key)] = loss for key, loss in self._l2_losses.items(): ops[util.with_prefix(self._name, key)] = loss self._exported_ops.update({'losses': [f'{self._name}/{k}' for k in self._losses.keys()], 'l2_losses': [f'{self._name}/{k}' for k in self._l2_losses.keys()]}) ops.update({f'{name}/cur_epoch': self._cur_epoch, f'{name}/global_step': self._global_step}) self._exported_ops.update({'epoch_and_step': [f'{name}/cur_epoch', f'{name}/global_step']}) if self._is_training: for key, train_op in self._train_ops.items(): ops[key] = train_op self._exported_ops.update({'train_ops': self._train_ops.keys()}) ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update, new_val=self._new_val, update_epoch=self._update_epoch) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, "initial") self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost} if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) for name, op in ops.items(): tf.add_to_collection(name, op) self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost, util.with_prefix(self._name, "probabilities"): self._probabilities} if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) if self._rnn_params: ops.update(rnn_params=self._rnn_params) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, "initial") self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost} if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) if self._rnn_params: ops.update(rnn_params=self._rnn_params) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, "initial") self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections. The collection is managed by tensorflow""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost} if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) if self._rnn_params: ops.update(rnn_params=self._rnn_params) for n, op in ops.items(): tf.add_to_collection(n, op) self._initial_state_name = util.with_prefix(self._name, 'initial') self._final_state_name = util.with_prefix(self._name, 'final') util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost} if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update, params_size=self._params_size) if FLAGS.num_gpus: ops.update(memory_use=self._memory_use) if self._rnn_params: ops.update(rnn_params=self._rnn_params) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, "initial") self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): self._name = name ops = {util.with_prefix(self._name, 'cost'): self._cost} tf.add_to_collection(util.with_prefix(self._name, 'logits'), self._logits) if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) if self._rnn_params: ops.update(rnn_params=self._rnn_params) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, 'initial') self._final_state_name = util.with_prefix(self._name, 'final') util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, 'cost'): self._cost} if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) if self._rnn_params: ops.update(rnn_params=self._rnn_params) if self.model_type == 'test': ops.update(logits=self.logits, y=self.y) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, 'initial') self._final_state_name = util.with_prefix(self._name, 'final') util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost, util.with_prefix(self._name, "kl_div"): self._kl_loss, util.with_prefix(self._name, "input_data"): self._input_data, util.with_prefix(self._name, "output"): self._output, util.with_prefix(self._name, "targets"): self._targets, } if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, "initial") self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = { util.with_prefix(self._name, "cost"): self._cost, util.with_prefix(self._name, "kl_div"): self._kl_loss, util.with_prefix(self._name, "input_data"): self._input_data, util.with_prefix(self._name, "output"): self._output, util.with_prefix(self._name, "targets"): self._targets, } if self._is_training: ops.update(lr=self._lr, new_lr=self._new_lr, lr_update=self._lr_update) for name, op in ops.items(): tf.add_to_collection(name, op) self._initial_state_name = util.with_prefix(self._name, "initial") self._final_state_name = util.with_prefix(self._name, "final") util.export_state_tuples(self._initial_state, self._initial_state_name) util.export_state_tuples(self._final_state, self._final_state_name)
from __future__ import absolute_import