Python tensorflow.contrib.slim.create_global_step() Examples
The following are 2
code examples of tensorflow.contrib.slim.create_global_step().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.contrib.slim
, or try the search function
.
Example #1
Source File: slim_train_test.py From SSD_tensorflow_VOC with Apache License 2.0 | 4 votes |
def __setup_training(self,images, labels): tf.logging.set_verbosity(tf.logging.INFO) logits, end_points = self.network_fn(images) ############################# # Specify the loss function # ############################# loss_1 = None if 'AuxLogits' in end_points: loss_1 = tf.losses.softmax_cross_entropy( logits=end_points['AuxLogits'], onehot_labels=labels, label_smoothing=self.label_smoothing, weights=0.4, scope='aux_loss') total_loss = tf.losses.softmax_cross_entropy( logits=logits, onehot_labels=labels, label_smoothing=self.label_smoothing, weights=1.0) if loss_1 is not None: total_loss = total_loss + loss_1 global_step = slim.create_global_step() # Variables to train. variables_to_train = self.__get_variables_to_train() learning_rate = self.__configure_learning_rate(self.dataset.num_samples, global_step) optimizer = self.__configure_optimizer(learning_rate) train_op = slim.learning.create_train_op(total_loss, optimizer, variables_to_train=variables_to_train) self.__add_summaries(end_points, learning_rate, total_loss) ########################### # Kicks off the training. # ########################### slim.learning.train( train_op, logdir=self.train_dir, init_fn=self.__get_init_fn(), number_of_steps=self.max_number_of_steps, log_every_n_steps=self.log_every_n_steps, save_summaries_secs=self.save_summaries_secs, save_interval_secs=self.save_interval_secs) return
Example #2
Source File: train_model.py From SSD_tensorflow_VOC with Apache License 2.0 | 4 votes |
def __start_training(self): tf.logging.set_verbosity(tf.logging.INFO) #get batched training training data image, filename,glabels,gbboxes,gdifficults,gclasses, localizations, gscores = self.get_voc_2007_2012_train_data() #get model outputs predictions, localisations, logits, end_points = g_ssd_model.get_model(image, weight_decay=self.weight_decay, is_training=True) #get model training losss total_loss = g_ssd_model.get_losses(logits, localisations, gclasses, localizations, gscores) global_step = slim.create_global_step() # Variables to train. variables_to_train = self.__get_variables_to_train() learning_rate = self.__configure_learning_rate(self.dataset.num_samples, global_step) optimizer = self.__configure_optimizer(learning_rate) train_op = slim.learning.create_train_op(total_loss, optimizer, variables_to_train=variables_to_train) self.__add_summaries(end_points, learning_rate, total_loss) self.setup_debugging(predictions, localizations, glabels, gbboxes, gdifficults) gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.9) config = tf.ConfigProto(log_device_placement=False, gpu_options=gpu_options) ########################### # Kicks off the training. # ########################### slim.learning.train( train_op, self.train_dir, train_step_fn=self.train_step, saver=tf_saver.Saver(max_to_keep=500), init_fn=self.__get_init_fn(), number_of_steps=self.max_number_of_steps, log_every_n_steps=self.log_every_n_steps, save_summaries_secs=self.save_summaries_secs, # session_config=config, save_interval_secs=self.save_interval_secs) return