當前位置: 首頁>>代碼示例>>Python>>正文


Python slim.create_global_step方法代碼示例

本文整理匯總了Python中tensorflow.contrib.slim.create_global_step方法的典型用法代碼示例。如果您正苦於以下問題:Python slim.create_global_step方法的具體用法?Python slim.create_global_step怎麽用?Python slim.create_global_step使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.contrib.slim的用法示例。


在下文中一共展示了slim.create_global_step方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __setup_training

# 需要導入模塊: from tensorflow.contrib import slim [as 別名]
# 或者: from tensorflow.contrib.slim import create_global_step [as 別名]
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 
開發者ID:LevinJ,項目名稱:SSD_tensorflow_VOC,代碼行數:51,代碼來源:slim_train_test.py

示例2: __start_training

# 需要導入模塊: from tensorflow.contrib import slim [as 別名]
# 或者: from tensorflow.contrib.slim import create_global_step [as 別名]
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 
開發者ID:LevinJ,項目名稱:SSD_tensorflow_VOC,代碼行數:53,代碼來源:train_model.py


注:本文中的tensorflow.contrib.slim.create_global_step方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。