Python official.utils.logs.hooks.ExamplesPerSecondHook() Examples
The following are 30
code examples of official.utils.logs.hooks.ExamplesPerSecondHook().
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
official.utils.logs.hooks
, or try the search function
.
Example #1
Source File: hooks_helper.py From g-tensorflow-models with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #2
Source File: hooks_helper.py From models with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #3
Source File: hooks_helper.py From Gun-Detector with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook(every_n_steps=every_n_steps, batch_size=batch_size, warm_steps=warm_steps)
Example #4
Source File: hooks_test.py From nsfw with Apache License 2.0 | 6 votes |
def _validate_log_every_n_secs(self, every_n_secs): hook = hooks.ExamplesPerSecondHook( batch_size=256, every_n_steps=None, every_n_secs=every_n_secs, metric_logger=self._logger) with tf.train.MonitoredSession( tf.train.ChiefSessionCreator(), [hook]) as mon_sess: # Explicitly run global_step after train_op to get the accurate # global_step value mon_sess.run(self.train_op) mon_sess.run(self.global_step) # Nothing should be in the list yet self.assertFalse(self._logger.logged_metric) time.sleep(every_n_secs) mon_sess.run(self.train_op) mon_sess.run(self.global_step) self._assert_metrics()
Example #5
Source File: hooks_helper.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #6
Source File: hooks_helper.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #7
Source File: hooks_helper.py From ml-on-gcp with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #8
Source File: hooks_helper.py From models with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #9
Source File: hooks_helper.py From models with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #10
Source File: hooks_helper.py From models with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #11
Source File: hooks_helper.py From models with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook(every_n_steps=every_n_steps, batch_size=batch_size, warm_steps=warm_steps)
Example #12
Source File: hooks_helper.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #13
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_fp16_8_gpu_nccl_tweaked(self): """Benchmarks graph fp16 8 gpus with nccl collective tweaked.""" self._setup() FLAGS.num_gpus = 8 FLAGS.distribution_strategy = 'multi_worker_mirrored' FLAGS.all_reduce_alg = 'nccl' FLAGS.tf_gpu_thread_mode = 'gpu_private' FLAGS.intra_op_parallelism_threads = 1 FLAGS.datasets_num_private_threads = 32 FLAGS.model_dir = self._get_model_dir( folder_name='benchmark_graph_fp16_8_gpu_nccl_tweaked') FLAGS.batch_size = 256*8 FLAGS.dtype = 'fp16' FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #14
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_8_gpu(self): """Benchmark graph mode 8 gpus. SOTA is 28.4 BLEU (uncased). """ self._setup() FLAGS.num_gpus = 8 FLAGS.data_dir = self.train_data_dir FLAGS.vocab_file = self.vocab_file # Sets values directly to avoid validation check. FLAGS['bleu_source'].value = self.bleu_source FLAGS['bleu_ref'].value = self.bleu_ref FLAGS.param_set = 'big' FLAGS.batch_size = 3072 * 8 FLAGS.train_steps = 100000 FLAGS.steps_between_evals = 5000 FLAGS.model_dir = self._get_model_dir('benchmark_graph_8_gpu') FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #15
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_8_gpu_static_batch(self): """Benchmark graph mode 8 gpus. SOTA is 28.4 BLEU (uncased). """ self._setup() FLAGS.num_gpus = 8 FLAGS.data_dir = self.train_data_dir FLAGS.vocab_file = self.vocab_file # Sets values directly to avoid validation check. FLAGS['bleu_source'].value = self.bleu_source FLAGS['bleu_ref'].value = self.bleu_ref FLAGS.param_set = 'big' FLAGS.batch_size = 3072 * 8 FLAGS.static_batch = True FLAGS.max_length = 64 FLAGS.train_steps = 100000 FLAGS.steps_between_evals = 5000 FLAGS.model_dir = self._get_model_dir('benchmark_graph_8_gpu') FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #16
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_2_gpu(self): """Benchmark graph mode 2 gpus. The paper uses 8 GPUs and a much larger effective batch size, this is will not converge to the 27.3 BLEU (uncased) SOTA. """ self._setup() FLAGS.num_gpus = 2 FLAGS.data_dir = self.train_data_dir FLAGS.vocab_file = self.vocab_file # Sets values directly to avoid validation check. FLAGS['bleu_source'].value = self.bleu_source FLAGS['bleu_ref'].value = self.bleu_ref FLAGS.param_set = 'base' FLAGS.batch_size = 4096 * 2 FLAGS.train_steps = 100000 FLAGS.steps_between_evals = 5000 FLAGS.model_dir = self._get_model_dir('benchmark_graph_2_gpu') FLAGS.hooks = ['ExamplesPerSecondHook'] # These bleu scores are based on test runs after at this limited # number of steps and batch size after verifying SOTA at 8xV100s. self._run_and_report_benchmark(bleu_min=25.3, bleu_max=26)
Example #17
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_8_gpu_static_batch(self): """Benchmark graph mode 8 gpus. SOTA is 27.3 BLEU (uncased). Best so far is 27.2 with 4048*8 at 75,000 steps. 27.009 with 4096*8 at 100,000 steps and earlier. Other test: 2024 * 8 peaked at 26.66 at 100,000 steps. """ self._setup() FLAGS.num_gpus = 8 FLAGS.data_dir = self.train_data_dir FLAGS.vocab_file = self.vocab_file # Sets values directly to avoid validation check. FLAGS['bleu_source'].value = self.bleu_source FLAGS['bleu_ref'].value = self.bleu_ref FLAGS.param_set = 'base' FLAGS.batch_size = 4096 * 8 FLAGS.static_batch = True FLAGS.max_length = 64 FLAGS.train_steps = 100000 FLAGS.steps_between_evals = 5000 FLAGS.model_dir = self._get_model_dir('benchmark_graph_8_gpu') FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #18
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_fp16_8_gpu(self): """benchmark 8 gpus with fp16 mixed precision. SOTA is 27.3 BLEU (uncased). """ self._setup() FLAGS.num_gpus = 8 FLAGS.dtype = 'fp16' FLAGS.data_dir = self.train_data_dir FLAGS.vocab_file = self.vocab_file # Sets values directly to avoid validation check. FLAGS['bleu_source'].value = self.bleu_source FLAGS['bleu_ref'].value = self.bleu_ref FLAGS.param_set = 'base' FLAGS.batch_size = 4096 * 8 FLAGS.train_steps = 100000 FLAGS.steps_between_evals = 5000 FLAGS.model_dir = self._get_model_dir('benchmark_graph_fp16_8_gpu') FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #19
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def benchmark_graph_fp16_8_gpu_ring_tweaked(self): """Benchmarks graph fp16 8 gpus with ring collective tweaked.""" self._setup() FLAGS.num_gpus = 8 FLAGS.distribution_strategy = 'multi_worker_mirrored' FLAGS.all_reduce_alg = 'ring' FLAGS.tf_gpu_thread_mode = 'gpu_private' FLAGS.intra_op_parallelism_threads = 1 FLAGS.datasets_num_private_threads = 32 FLAGS.model_dir = self._get_model_dir( folder_name='benchmark_graph_fp16_8_gpu_ring_tweaked') FLAGS.batch_size = 256*8 FLAGS.dtype = 'fp16' FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #20
Source File: hooks_helper.py From cloudml-samples with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook( batch_size=batch_size, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=logger.get_benchmark_logger())
Example #21
Source File: hooks_helper.py From training with Apache License 2.0 | 6 votes |
def get_examples_per_second_hook(every_n_steps=100, batch_size=128, warm_steps=5, **kwargs): # pylint: disable=unused-argument """Function to get ExamplesPerSecondHook. Args: every_n_steps: `int`, print current and average examples per second every N steps. batch_size: `int`, total batch size used to calculate examples/second from global time. warm_steps: skip this number of steps before logging and running average. **kwargs: a dictionary of arguments to ExamplesPerSecondHook. Returns: Returns a ProfilerHook that writes out timelines that can be loaded into profiling tools like chrome://tracing. """ return hooks.ExamplesPerSecondHook(every_n_steps=every_n_steps, batch_size=batch_size, warm_steps=warm_steps)
Example #22
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def __init__(self, output_dir=None, root_data_dir=None, **kwargs): train_data_dir = os.path.join(root_data_dir, TRANSFORMER_EN2DE_DATA_DIR_NAME) vocab_file = os.path.join(root_data_dir, TRANSFORMER_EN2DE_DATA_DIR_NAME, 'vocab.ende.32768') def_flags = {} def_flags['param_set'] = 'base' def_flags['vocab_file'] = vocab_file def_flags['data_dir'] = train_data_dir def_flags['train_steps'] = 200 def_flags['steps_between_evals'] = 200 def_flags['hooks'] = ['ExamplesPerSecondHook'] super(TransformerBaseEstimatorBenchmarkReal, self).__init__( output_dir=output_dir, default_flags=def_flags)
Example #23
Source File: transformer_estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def __init__(self, output_dir=None, root_data_dir=None, **kwargs): train_data_dir = os.path.join(root_data_dir, TRANSFORMER_EN2DE_DATA_DIR_NAME) vocab_file = os.path.join(root_data_dir, TRANSFORMER_EN2DE_DATA_DIR_NAME, 'vocab.ende.32768') def_flags = {} def_flags['param_set'] = 'big' def_flags['vocab_file'] = vocab_file def_flags['data_dir'] = train_data_dir def_flags['train_steps'] = 200 def_flags['steps_between_evals'] = 200 def_flags['hooks'] = ['ExamplesPerSecondHook'] super(TransformerBigEstimatorBenchmarkReal, self).__init__( output_dir=output_dir, default_flags=def_flags, batch_per_gpu=3072)
Example #24
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def benchmark_graph_fp16_1_gpu(self): """Benchmarks graph fp16 1 gpu.""" self._setup() FLAGS.num_gpus = 1 FLAGS.model_dir = self._get_model_dir('benchmark_graph_fp16_1_gpu') FLAGS.batch_size = 128 FLAGS.dtype = 'fp16' FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #25
Source File: hooks_helper.py From Gun-Detector with Apache License 2.0 | 5 votes |
def get_train_hooks(name_list, **kwargs): """Factory for getting a list of TensorFlow hooks for training by name. Args: name_list: a list of strings to name desired hook classes. Allowed: LoggingTensorHook, ProfilerHook, ExamplesPerSecondHook, which are defined as keys in HOOKS **kwargs: a dictionary of arguments to the hooks. Returns: list of instantiated hooks, ready to be used in a classifier.train call. Raises: ValueError: if an unrecognized name is passed. """ if not name_list: return [] train_hooks = [] for name in name_list: hook_name = HOOKS.get(name.strip().lower()) if hook_name is None: raise ValueError('Unrecognized training hook requested: {}'.format(name)) else: train_hooks.append(hook_name(**kwargs)) return train_hooks
Example #26
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def benchmark_graph_1_gpu(self): """Test layers model with Estimator and distribution strategies.""" self._setup() flags.FLAGS.num_gpus = 1 flags.FLAGS.data_dir = self.data_dir flags.FLAGS.batch_size = 128 flags.FLAGS.train_epochs = 182 flags.FLAGS.model_dir = self._get_model_dir('benchmark_graph_1_gpu') flags.FLAGS.resnet_size = 56 flags.FLAGS.dtype = 'fp32' flags.FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #27
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def benchmark_graph_fp16_1_gpu(self): """Test layers FP16 model with Estimator and distribution strategies.""" self._setup() flags.FLAGS.num_gpus = 1 flags.FLAGS.data_dir = self.data_dir flags.FLAGS.batch_size = 128 flags.FLAGS.train_epochs = 182 flags.FLAGS.model_dir = self._get_model_dir('benchmark_graph_fp16_1_gpu') flags.FLAGS.resnet_size = 56 flags.FLAGS.dtype = 'fp16' flags.FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #28
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def benchmark_graph_2_gpu(self): """Test layers model with Estimator and dist_strat. 2 GPUs.""" self._setup() flags.FLAGS.num_gpus = 2 flags.FLAGS.data_dir = self.data_dir flags.FLAGS.batch_size = 128 flags.FLAGS.train_epochs = 182 flags.FLAGS.model_dir = self._get_model_dir('benchmark_graph_2_gpu') flags.FLAGS.resnet_size = 56 flags.FLAGS.dtype = 'fp32' flags.FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()
Example #29
Source File: hooks_test.py From nsfw with Apache License 2.0 | 5 votes |
def _validate_log_every_n_steps(self, every_n_steps, warm_steps): hook = hooks.ExamplesPerSecondHook( batch_size=256, every_n_steps=every_n_steps, warm_steps=warm_steps, metric_logger=self._logger) with tf.train.MonitoredSession( tf.train.ChiefSessionCreator(), [hook]) as mon_sess: for _ in range(every_n_steps): # Explicitly run global_step after train_op to get the accurate # global_step value mon_sess.run(self.train_op) mon_sess.run(self.global_step) # Nothing should be in the list yet self.assertFalse(self._logger.logged_metric) mon_sess.run(self.train_op) global_step_val = mon_sess.run(self.global_step) if global_step_val > warm_steps: self._assert_metrics() else: # Nothing should be in the list yet self.assertFalse(self._logger.logged_metric) # Add additional run to verify proper reset when called multiple times. prev_log_len = len(self._logger.logged_metric) mon_sess.run(self.train_op) global_step_val = mon_sess.run(self.global_step) if every_n_steps == 1 and global_step_val > warm_steps: # Each time, we log two additional metrics. Did exactly 2 get added? self.assertEqual(len(self._logger.logged_metric), prev_log_len + 2) else: # No change in the size of the metric list. self.assertEqual(len(self._logger.logged_metric), prev_log_len)
Example #30
Source File: estimator_benchmark.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def unit_test(self): """A lightweight test that can finish quickly.""" self._setup() flags.FLAGS.num_gpus = 1 flags.FLAGS.data_dir = self.data_dir flags.FLAGS.batch_size = 128 flags.FLAGS.train_epochs = 1 flags.FLAGS.model_dir = self._get_model_dir('unit_test') flags.FLAGS.resnet_size = 8 flags.FLAGS.dtype = 'fp32' flags.FLAGS.hooks = ['ExamplesPerSecondHook'] self._run_and_report_benchmark()