def test_optimizer_momentum_rmsprop(system_dict): forward = True; if(not os.path.isdir("datasets")): os.system("! wget --load-cookies /tmp/cookies.txt \"https://docs.google.com/uc?export=download&confirm=$(wget --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1rG-U1mS8hDU7_wM56a1kc-li_zHLtbq2' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1rG-U1mS8hDU7_wM56a1kc-li_zHLtbq2\" -O datasets.zip && rm -rf /tmp/cookies.txt") os.system("! unzip -qq datasets.zip") test = "test_optimizer_momentum_rmsprop"; system_dict["total_tests"] += 1; print_start(test, system_dict["total_tests"]) if(forward): try: gtf = prototype(verbose=0); gtf.Prototype("sample-project-1", "sample-experiment-1"); gtf.Default(dataset_path="datasets/dataset_cats_dogs_train", model_name="resnet18", freeze_base_network=True, num_epochs=2); gtf.optimizer_momentum_rmsprop(0.01, weight_decay=0.0001, decay_rate=0.9); gtf.Train(); system_dict["successful_tests"] += 1; print_status("Pass"); except Exception as e: system_dict["failed_tests_exceptions"].append(e); system_dict["failed_tests_lists"].append(test); forward = False; print_status("Fail"); else: system_dict["skipped_tests_lists"].append(test); print_status("Skipped"); return system_dict
def test_activation_softmin(system_dict): forward = True test = "test_activation_softmin" system_dict["total_tests"] += 1 print_start(test, system_dict["total_tests"]) if (forward): try: gtf = prototype(verbose=0) gtf.Prototype("sample-project-1", "sample-experiment-1") network = [] network.append(gtf.softmin()) gtf.Compile_Network(network, data_shape=(3, 64, 64), use_gpu=False) x = torch.randn(1, 3, 64, 64) y = gtf.system_dict["local"]["model"](x) system_dict["successful_tests"] += 1 print_status("Pass") except Exception as e: system_dict["failed_tests_exceptions"].append(e) system_dict["failed_tests_lists"].append(test) forward = False print_status("Fail") else: system_dict["skipped_tests_lists"].append(test) print_status("Skipped") return system_dict
def test_activation_rrelu(system_dict): forward = True; test = "test_activation_rrelu"; system_dict["total_tests"] += 1; print_start(test, system_dict["total_tests"]) if(forward): try: gtf = prototype(verbose=0); gtf.Prototype("sample-project-1", "sample-experiment-1"); network = []; network.append(gtf.rrelu()); gtf.Compile_Network(network, data_shape=(3, 64, 64), use_gpu=False); x = torch.randn(1, 3, 64, 64); y = gtf.system_dict["local"]["model"](x); system_dict["successful_tests"] += 1; print_status("Pass"); except Exception as e: system_dict["failed_tests_exceptions"].append(e); system_dict["failed_tests_lists"].append(test); forward = False; print_status("Fail"); else: system_dict["skipped_tests_lists"].append(test); print_status("Skipped"); return system_dict
def test_loss_kldiv(system_dict): forward = True test = "test_loss_kldiv" system_dict["total_tests"] += 1 print_start(test, system_dict["total_tests"]) if (forward): try: gtf = prototype(verbose=0) gtf.Prototype("sample-project-1", "sample-experiment-1") label = torch.randn(1, 5) y = torch.randn(1, 5) gtf.loss_kldiv() load_loss(gtf.system_dict) loss_obj = gtf.system_dict["local"]["criterion"] loss_val = loss_obj(y, label) system_dict["successful_tests"] += 1 print_status("Pass") except Exception as e: system_dict["failed_tests_exceptions"].append(e) system_dict["failed_tests_lists"].append(test) forward = False print_status("Fail") else: system_dict["skipped_tests_lists"].append(test) print_status("Skipped") return system_dict
def test_block_densenet(system_dict): forward = True; test = "test_block_densenet"; system_dict["total_tests"] += 1; print_start(test, system_dict["total_tests"]) if(forward): try: gtf = prototype(verbose=0); gtf.Prototype("sample-project-1", "sample-experiment-1"); network = []; network.append(gtf.densenet_block(bottleneck_size=4, growth_rate=16, dropout=0.2)); gtf.Compile_Network(network, data_shape=(1, 64, 64), use_gpu=False); x = torch.randn(1, 1, 64, 64); y = gtf.system_dict["local"]["model"](x); system_dict["successful_tests"] += 1; print_status("Pass"); except Exception as e: system_dict["failed_tests_exceptions"].append(e); system_dict["failed_tests_lists"].append(test); forward = False; print_status("Fail"); else: system_dict["skipped_tests_lists"].append(test); print_status("Skipped"); return system_dict
def test_loss_sigmoid_binary_crossentropy(system_dict): forward = True; test = "test_loss_sigmoid_binary_crossentropy"; system_dict["total_tests"] += 1; print_start(test, system_dict["total_tests"]) if(forward): try: gtf = prototype(verbose=0); gtf.Prototype("sample-project-1", "sample-experiment-1"); label = torch.empty((1, 5)).random_(2); y = torch.randn(1, 5); gtf.loss_sigmoid_binary_crossentropy(); load_loss(gtf.system_dict); loss_obj = gtf.system_dict["local"]["criterion"]; loss_val = loss_obj(y, label); system_dict["successful_tests"] += 1; print_status("Pass"); except Exception as e: system_dict["failed_tests_exceptions"].append(e); system_dict["failed_tests_lists"].append(test); forward = False; print_status("Fail"); else: system_dict["skipped_tests_lists"].append(test); print_status("Skipped"); return system_dict
def test_block_inception_a(system_dict): forward = True; test = "test_block_inception_a"; system_dict["total_tests"] += 1; print_start(test, system_dict["total_tests"]) if(forward): try: gtf = prototype(verbose=0); gtf.Prototype("sample-project-1", "sample-experiment-1"); network = []; network.append(gtf.inception_a_block(pooling_branch_channels=32, pool_type="avg")); network.append(gtf.inception_a_block(pooling_branch_channels=32, pool_type="max")); gtf.Compile_Network(network, data_shape=(1, 64, 64), use_gpu=False); x = torch.randn(1, 1, 64, 64); y = gtf.system_dict["local"]["model"](x); system_dict["successful_tests"] += 1; print_status("Pass"); except Exception as e: system_dict["failed_tests_exceptions"].append(e); system_dict["failed_tests_lists"].append(test); forward = False; print_status("Fail"); else: system_dict["skipped_tests_lists"].append(test); print_status("Skipped"); return system_dict
def test_layer_transposed_convolution2d(system_dict): forward = True test = "test_layer_transposed_convolution2d" system_dict["total_tests"] += 1 print_start(test, system_dict["total_tests"]) if (forward): try: gtf = prototype(verbose=0) gtf.Prototype("sample-project-1", "sample-experiment-1") network = [] network.append( gtf.transposed_convolution2d(output_channels=3, kernel_size=3)) gtf.Compile_Network(network, data_shape=(3, 128, 128), use_gpu=False) x = torch.randn(1, 3, 128, 128) y = gtf.system_dict["local"]["model"](x) system_dict["successful_tests"] += 1 print_status("Pass") except Exception as e: system_dict["failed_tests_exceptions"].append(e) system_dict["failed_tests_lists"].append(test) forward = False print_status("Fail") else: system_dict["skipped_tests_lists"].append(test) print_status("Skipped") return system_dict
def test_block_resnet_v2_bottleneck(system_dict): forward = True; test = "test_block_resnet_v2_bottleneck"; system_dict["total_tests"] += 1; print_start(test, system_dict["total_tests"]) if(forward): try: gtf = prototype(verbose=0); gtf.Prototype("sample-project-1", "sample-experiment-1"); network = []; network.append(gtf.resnet_v2_bottleneck_block(output_channels=32, stride=1, downsample=True)); network.append(gtf.resnet_v2_bottleneck_block(output_channels=32, stride=1, downsample=False)); gtf.Compile_Network(network, data_shape=(1, 64, 64), use_gpu=False); x = torch.randn(1, 1, 64, 64); y = gtf.system_dict["local"]["model"](x); system_dict["successful_tests"] += 1; print_status("Pass"); except Exception as e: system_dict["failed_tests_exceptions"].append(e); system_dict["failed_tests_lists"].append(test); forward = False; print_status("Fail"); else: system_dict["skipped_tests_lists"].append(test); print_status("Skipped"); return system_dict
def test_block_resnext(system_dict): forward = True test = "test_block_resnext" system_dict["total_tests"] += 1 print_start(test, system_dict["total_tests"]) if (forward): try: gtf = prototype(verbose=0) gtf.Prototype("sample-project-1", "sample-experiment-1") network = [] network.append( gtf.resnext_block(output_channels=256, cardinality=8, bottleneck_width=4, stride=1, downsample=True)) network.append( gtf.resnext_block(output_channels=256, cardinality=8, bottleneck_width=4, stride=1, downsample=False)) gtf.Compile_Network(network, data_shape=(1, 64, 64), use_gpu=False) x = torch.randn(1, 1, 64, 64) y = gtf.system_dict["local"]["model"](x) system_dict["successful_tests"] += 1 print_status("Pass") except Exception as e: system_dict["failed_tests_exceptions"].append(e) system_dict["failed_tests_lists"].append(test) forward = False print_status("Fail") else: system_dict["skipped_tests_lists"].append(test) print_status("Skipped") return system_dict
def test_layer_concatenate(system_dict): forward = True test = "test_layer_concatenate" system_dict["total_tests"] += 1 print_start(test, system_dict["total_tests"]) if (forward): try: gtf = prototype(verbose=0) gtf.Prototype("sample-project-1", "sample-experiment-1") network = [] network.append(gtf.convolution(output_channels=16)) network.append(gtf.batch_normalization()) network.append(gtf.relu()) network.append(gtf.max_pooling()) subnetwork = [] branch1 = [] branch1.append(gtf.convolution(output_channels=16)) branch1.append(gtf.batch_normalization()) branch1.append(gtf.convolution(output_channels=16)) branch1.append(gtf.batch_normalization()) branch2 = [] branch2.append(gtf.convolution(output_channels=16)) branch2.append(gtf.batch_normalization()) branch3 = [] branch3.append(gtf.identity()) subnetwork.append(branch1) subnetwork.append(branch2) subnetwork.append(branch3) subnetwork.append(gtf.concatenate()) network.append(subnetwork) network.append(gtf.convolution(output_channels=16)) network.append(gtf.batch_normalization()) network.append(gtf.relu()) network.append(gtf.max_pooling()) network.append(gtf.flatten()) network.append(gtf.fully_connected(units=1024)) network.append(gtf.dropout(drop_probability=0.2)) network.append(gtf.fully_connected(units=2)) gtf.Compile_Network(network, data_shape=(3, 64, 64), use_gpu=False) x = torch.randn(1, 3, 64, 64) y = gtf.system_dict["local"]["model"](x) system_dict["successful_tests"] += 1 print_status("Pass") except Exception as e: system_dict["failed_tests_exceptions"].append(e) system_dict["failed_tests_lists"].append(test) forward = False print_status("Fail") else: system_dict["skipped_tests_lists"].append(test) print_status("Skipped") return system_dict