Python tensorflow.python.platform.googletest.main() Examples
The following are 25
code examples of tensorflow.python.platform.googletest.main().
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.python.platform.googletest
, or try the search function
.
Example #1
Source File: curses_ui_test.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def testMouseClickOffLinkDoesNotTriggersCommand(self): ui = MockCursesUI( 40, 80, command_sequence=[ string_to_codes("babble -n 10 -k\n"), # A click off a hyperlink (too much to the right). [curses.KEY_MOUSE, 8, 4], self._EXIT ]) ui.register_command_handler("babble", self._babble, "") ui.run_ui() # The mouse click event should not triggered no command. self.assertEqual(1, len(ui.unwrapped_outputs)) self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[0].lines) # This command should have generated no main menus. self.assertEqual([None], ui.main_menu_list)
Example #2
Source File: curses_ui_test.py From keras-lambda with MIT License | 6 votes |
def testMouseClickOffLinkDoesNotTriggersCommand(self): ui = MockCursesUI( 40, 80, command_sequence=[ string_to_codes("babble -n 10 -k\n"), # A click off a hyperlink (too much to the right). [curses.KEY_MOUSE, 8, 4], self._EXIT ]) ui.register_command_handler("babble", self._babble, "") ui.run_ui() # The mouse click event should not triggered no command. self.assertEqual(1, len(ui.unwrapped_outputs)) self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[0].lines) # This command should have generated no main menus. self.assertEqual([None], ui.main_menu_list)
Example #3
Source File: resnet_cifar_test.py From models with Apache License 2.0 | 6 votes |
def test_end_to_end_2_gpu(self): """Test Keras model with 2 GPUs.""" if context.num_gpus() < 2: self.skipTest( "{} GPUs are not available for this test. {} GPUs are available". format(2, context.num_gpus())) extra_flags = [ "-num_gpus", "2", "-distribution_strategy", "mirrored", "-model_dir", "keras_cifar_2_gpu", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #4
Source File: resnet_cifar_test.py From models with Apache License 2.0 | 6 votes |
def test_end_to_end_graph_1_gpu(self): """Test Keras model in legacy graph mode with 1 GPU.""" if context.num_gpus() < 1: self.skipTest( "{} GPUs are not available for this test. {} GPUs are available". format(1, context.num_gpus())) extra_flags = [ "-num_gpus", "1", "-noenable_eager", "-distribution_strategy", "mirrored", "-model_dir", "keras_cifar_graph_1_gpu", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #5
Source File: resnet_cifar_test.py From models with Apache License 2.0 | 6 votes |
def test_end_to_end_1_gpu(self): """Test Keras model with 1 GPU.""" if context.num_gpus() < 1: self.skipTest( "{} GPUs are not available for this test. {} GPUs are available". format(1, context.num_gpus())) extra_flags = [ "-num_gpus", "1", "-distribution_strategy", "mirrored", "-model_dir", "keras_cifar_1_gpu", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #6
Source File: ctl_imagenet_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def test_end_to_end_2_gpu(self): """Test Keras model with 2 GPUs.""" num_gpus = '2' if context.num_gpus() < 2: num_gpus = '0' extra_flags = [ '-num_gpus', num_gpus, '-distribution_strategy', 'default', '-model_dir', 'ctl_imagenet_2_gpu', '-data_format', 'channels_last', ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=ctl_imagenet_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #7
Source File: resnet_cifar_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def test_end_to_end_no_dist_strat(self): """Test Keras model with 1 GPU, no distribution strategy.""" config = keras_utils.get_config_proto_v1() tf.compat.v1.enable_eager_execution(config=config) extra_flags = [ "-distribution_strategy", "off", "-model_dir", "keras_cifar_no_dist_strat", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #8
Source File: resnet_cifar_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def test_end_to_end_1_gpu(self): """Test Keras model with 1 GPU.""" config = keras_utils.get_config_proto_v1() tf.compat.v1.enable_eager_execution(config=config) if context.num_gpus() < 1: self.skipTest( "{} GPUs are not available for this test. {} GPUs are available". format(1, context.num_gpus())) extra_flags = [ "-num_gpus", "1", "-distribution_strategy", "default", "-model_dir", "keras_cifar_1_gpu", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #9
Source File: resnet_cifar_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def test_end_to_end_2_gpu(self): """Test Keras model with 2 GPUs.""" config = keras_utils.get_config_proto_v1() tf.compat.v1.enable_eager_execution(config=config) if context.num_gpus() < 2: self.skipTest( "{} GPUs are not available for this test. {} GPUs are available". format(2, context.num_gpus())) extra_flags = [ "-num_gpus", "2", "-distribution_strategy", "default", "-model_dir", "keras_cifar_2_gpu", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #10
Source File: resnet_cifar_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 6 votes |
def test_end_to_end_graph_2_gpu(self): """Test Keras model in legacy graph mode with 2 GPUs.""" if context.num_gpus() < 2: self.skipTest( "{} GPUs are not available for this test. {} GPUs are available". format(2, context.num_gpus())) extra_flags = [ "-num_gpus", "2", "-enable_eager", "false", "-distribution_strategy", "default", "-model_dir", "keras_cifar_graph_2_gpu", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #11
Source File: analyzer_cli_test.py From keras-lambda with MIT License | 5 votes |
def testListTensors(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", []) assert_listed_tensors(self, out, [ "simple_mul_add/u:0", "simple_mul_add/v:0", "simple_mul_add/u/read:0", "simple_mul_add/v/read:0", "simple_mul_add/matmul:0", "simple_mul_add/add:0" ], ["VariableV2", "VariableV2", "Identity", "Identity", "MatMul", "Add"]) # Check the main menu. check_main_menu(self, out, list_tensors_enabled=False)
Example #12
Source File: test.py From lambda-packs with MIT License | 5 votes |
def main(argv=None): """Runs all unit tests.""" return _googletest.main(argv)
Example #13
Source File: test.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def main(argv=None): """Runs all unit tests.""" return _googletest.main(argv)
Example #14
Source File: resnet_cifar_test.py From models with Apache License 2.0 | 5 votes |
def test_end_to_end_graph_no_dist_strat(self): """Test Keras model in legacy graph mode with 1 GPU, no dist strat.""" extra_flags = [ "-enable_eager", "false", "-distribution_strategy", "off", "-model_dir", "keras_cifar_graph_no_dist_strat", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #15
Source File: resnet_cifar_test.py From models with Apache License 2.0 | 5 votes |
def test_end_to_end_no_dist_strat(self): """Test Keras model with 1 GPU, no distribution strategy.""" extra_flags = [ "-distribution_strategy", "off", "-model_dir", "keras_cifar_no_dist_strat", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #16
Source File: resnet_cifar_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def test_end_to_end_graph_no_dist_strat(self): """Test Keras model in legacy graph mode with 1 GPU, no dist strat.""" extra_flags = [ "-enable_eager", "false", "-distribution_strategy", "off", "-model_dir", "keras_cifar_graph_no_dist_strat", "-data_format", "channels_last", ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=resnet_cifar_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #17
Source File: ctl_imagenet_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def test_end_to_end_no_dist_strat(self): """Test Keras model with 1 GPU, no distribution strategy.""" extra_flags = [ '-distribution_strategy', 'off', '-model_dir', 'ctl_imagenet_no_dist_strat', '-data_format', 'channels_last', ] extra_flags = extra_flags + self._extra_flags integration.run_synthetic( main=ctl_imagenet_main.run, tmp_root=self.get_temp_dir(), extra_flags=extra_flags )
Example #18
Source File: test.py From deep_image_model with Apache License 2.0 | 5 votes |
def main(): """Runs all unit tests.""" return _googletest.main()
Example #19
Source File: analyzer_cli_test.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def testListTensors(self): # Use shorthand alias for the command prefix. out = self._registry.dispatch_command("lt", []) assert_listed_tensors(self, out, [ "simple_mul_add/u:0", "simple_mul_add/v:0", "simple_mul_add/u/read:0", "simple_mul_add/v/read:0", "simple_mul_add/matmul:0", "simple_mul_add/add:0" ], ["VariableV2", "VariableV2", "Identity", "Identity", "MatMul", "Add"]) # Check the main menu. check_main_menu(self, out, list_tensors_enabled=False)
Example #20
Source File: analyzer_cli_test.py From auto-alt-text-lambda-api with MIT License | 4 votes |
def check_main_menu(tst, out, list_tensors_enabled=False, node_info_node_name=None, print_tensor_node_name=None, list_inputs_node_name=None, list_outputs_node_name=None): """Check the main menu annotation of an output.""" tst.assertIn(debugger_cli_common.MAIN_MENU_KEY, out.annotations) menu = out.annotations[debugger_cli_common.MAIN_MENU_KEY] tst.assertEqual(list_tensors_enabled, menu.caption_to_item("list_tensors").is_enabled()) menu_item = menu.caption_to_item("node_info") if node_info_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(node_info_node_name)) else: tst.assertFalse(menu_item.is_enabled()) menu_item = menu.caption_to_item("print_tensor") if print_tensor_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(print_tensor_node_name)) else: tst.assertFalse(menu_item.is_enabled()) menu_item = menu.caption_to_item("list_inputs") if list_inputs_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(list_inputs_node_name)) else: tst.assertFalse(menu_item.is_enabled()) menu_item = menu.caption_to_item("list_outputs") if list_outputs_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(list_outputs_node_name)) else: tst.assertFalse(menu_item.is_enabled()) tst.assertTrue(menu.caption_to_item("run_info").is_enabled()) tst.assertTrue(menu.caption_to_item("help").is_enabled())
Example #21
Source File: curses_ui_test.py From keras-lambda with MIT License | 4 votes |
def __init__(self, height, width, command_sequence=None): self._height = height self._width = width self._command_sequence = command_sequence self._command_counter = 0 # The mock class has no actual textbox. So use this variable to keep # track of what's entered in the textbox on creation. self._curr_existing_command = "" # Observers for test. # Observers of screen output. self.unwrapped_outputs = [] self.wrapped_outputs = [] self.scroll_messages = [] self.output_array_pointer_indices = [] self.output_pad_rows = [] # Observers of command textbox. self.existing_commands = [] # Observer for tab-completion candidates. self.candidates_lists = [] # Observer for the main menu. self.main_menu_list = [] # Observer for toast messages. self.toasts = [] curses_ui.CursesUI.__init__(self) # Below, override the _screen_ prefixed member methods that interact with the # actual terminal, so that the mock can run in a terminal-less environment. # TODO(cais): Search for a way to have a mock terminal object that behaves # like the actual terminal, so that we can test the terminal interaction # parts of the CursesUI class.
Example #22
Source File: cli_shared_test.py From auto-alt-text-lambda-api with MIT License | 4 votes |
def testSingleFetchNoFeeds(self): run_start_intro = cli_shared.get_run_start_intro(12, self.const_a, None, {}) # Verify line about run() call number. self.assertTrue(run_start_intro.lines[1].endswith("run() call #12:")) # Verify line about fetch. const_a_name_line = run_start_intro.lines[4] self.assertEqual(self.const_a.name, const_a_name_line.strip()) # Verify line about feeds. feeds_line = run_start_intro.lines[7] self.assertEqual("(Empty)", feeds_line.strip()) # Verify lines about possible commands and their font attributes. self.assertEqual("run:", run_start_intro.lines[11][2:]) annot = run_start_intro.font_attr_segs[11][0] self.assertEqual(2, annot[0]) self.assertEqual(5, annot[1]) self.assertEqual("run", annot[2][0].content) self.assertEqual("bold", annot[2][1]) annot = run_start_intro.font_attr_segs[13][0] self.assertEqual(2, annot[0]) self.assertEqual(8, annot[1]) self.assertEqual("run -n", annot[2][0].content) self.assertEqual("bold", annot[2][1]) self.assertEqual("run -t <T>:", run_start_intro.lines[15][2:]) self.assertEqual([(2, 12, "bold")], run_start_intro.font_attr_segs[15]) self.assertEqual("run -f <filter_name>:", run_start_intro.lines[17][2:]) self.assertEqual([(2, 22, "bold")], run_start_intro.font_attr_segs[17]) annot = run_start_intro.font_attr_segs[21][0] self.assertEqual(2, annot[0]) self.assertEqual(16, annot[1]) self.assertEqual("invoke_stepper", annot[2][0].content) # Verify short description. description = cli_shared.get_run_short_description(12, self.const_a, None) self.assertEqual("run #12: 1 fetch (a:0); 0 feeds", description) # Verify the main menu associated with the run_start_intro. self.assertIn(debugger_cli_common.MAIN_MENU_KEY, run_start_intro.annotations) menu = run_start_intro.annotations[debugger_cli_common.MAIN_MENU_KEY] self.assertEqual("run", menu.caption_to_item("run").content) self.assertEqual("invoke_stepper", menu.caption_to_item("invoke_stepper").content) self.assertEqual("exit", menu.caption_to_item("exit").content)
Example #23
Source File: cli_shared_test.py From keras-lambda with MIT License | 4 votes |
def testSingleFetchNoFeeds(self): run_start_intro = cli_shared.get_run_start_intro(12, self.const_a, None, {}) # Verify line about run() call number. self.assertTrue(run_start_intro.lines[1].endswith("run() call #12:")) # Verify line about fetch. const_a_name_line = run_start_intro.lines[4] self.assertEqual(self.const_a.name, const_a_name_line.strip()) # Verify line about feeds. feeds_line = run_start_intro.lines[7] self.assertEqual("(Empty)", feeds_line.strip()) # Verify lines about possible commands and their font attributes. self.assertEqual("run:", run_start_intro.lines[11][2:]) annot = run_start_intro.font_attr_segs[11][0] self.assertEqual(2, annot[0]) self.assertEqual(5, annot[1]) self.assertEqual("run", annot[2][0].content) self.assertEqual("bold", annot[2][1]) annot = run_start_intro.font_attr_segs[13][0] self.assertEqual(2, annot[0]) self.assertEqual(8, annot[1]) self.assertEqual("run -n", annot[2][0].content) self.assertEqual("bold", annot[2][1]) self.assertEqual("run -t <T>:", run_start_intro.lines[15][2:]) self.assertEqual([(2, 12, "bold")], run_start_intro.font_attr_segs[15]) self.assertEqual("run -f <filter_name>:", run_start_intro.lines[17][2:]) self.assertEqual([(2, 22, "bold")], run_start_intro.font_attr_segs[17]) annot = run_start_intro.font_attr_segs[21][0] self.assertEqual(2, annot[0]) self.assertEqual(16, annot[1]) self.assertEqual("invoke_stepper", annot[2][0].content) # Verify short description. description = cli_shared.get_run_short_description(12, self.const_a, None) self.assertEqual("run #12: 1 fetch (a:0); 0 feeds", description) # Verify the main menu associated with the run_start_intro. self.assertIn(debugger_cli_common.MAIN_MENU_KEY, run_start_intro.annotations) menu = run_start_intro.annotations[debugger_cli_common.MAIN_MENU_KEY] self.assertEqual("run", menu.caption_to_item("run").content) self.assertEqual("invoke_stepper", menu.caption_to_item("invoke_stepper").content) self.assertEqual("exit", menu.caption_to_item("exit").content)
Example #24
Source File: analyzer_cli_test.py From keras-lambda with MIT License | 4 votes |
def check_main_menu(tst, out, list_tensors_enabled=False, node_info_node_name=None, print_tensor_node_name=None, list_inputs_node_name=None, list_outputs_node_name=None): """Check the main menu annotation of an output.""" tst.assertIn(debugger_cli_common.MAIN_MENU_KEY, out.annotations) menu = out.annotations[debugger_cli_common.MAIN_MENU_KEY] tst.assertEqual(list_tensors_enabled, menu.caption_to_item("list_tensors").is_enabled()) menu_item = menu.caption_to_item("node_info") if node_info_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(node_info_node_name)) else: tst.assertFalse(menu_item.is_enabled()) menu_item = menu.caption_to_item("print_tensor") if print_tensor_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(print_tensor_node_name)) else: tst.assertFalse(menu_item.is_enabled()) menu_item = menu.caption_to_item("list_inputs") if list_inputs_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(list_inputs_node_name)) else: tst.assertFalse(menu_item.is_enabled()) menu_item = menu.caption_to_item("list_outputs") if list_outputs_node_name: tst.assertTrue(menu_item.is_enabled()) tst.assertTrue(menu_item.content.endswith(list_outputs_node_name)) else: tst.assertFalse(menu_item.is_enabled()) tst.assertTrue(menu.caption_to_item("run_info").is_enabled()) tst.assertTrue(menu.caption_to_item("help").is_enabled())
Example #25
Source File: curses_ui_test.py From auto-alt-text-lambda-api with MIT License | 4 votes |
def __init__(self, height, width, command_sequence=None): self._height = height self._width = width self._command_sequence = command_sequence self._command_counter = 0 # The mock class has no actual textbox. So use this variable to keep # track of what's entered in the textbox on creation. self._curr_existing_command = "" # Observers for test. # Observers of screen output. self.unwrapped_outputs = [] self.wrapped_outputs = [] self.scroll_messages = [] self.output_array_pointer_indices = [] self.output_pad_rows = [] # Observers of command textbox. self.existing_commands = [] # Observer for tab-completion candidates. self.candidates_lists = [] # Observer for the main menu. self.main_menu_list = [] # Observer for toast messages. self.toasts = [] curses_ui.CursesUI.__init__(self) # Below, override the _screen_ prefixed member methods that interact with the # actual terminal, so that the mock can run in a terminal-less environment. # TODO(cais): Search for a way to have a mock terminal object that behaves # like the actual terminal, so that we can test the terminal interaction # parts of the CursesUI class.