def test_native_module_library_with_in_out(self):
        @add_module()
        class Test(object):
            def __init__(self):
                pass

        test = Module.create("Test", **{"in": "foo", "out": "bar"})
        self.assertIsInstance(test, Test)
    def test_native_module_library(self):
        @add_module()
        class Test(object):
            def __init__(self):
                pass

        test = Module.create("Test")
        self.assertIsInstance(test, Test)
    def test_native_module_library_with_params(self):
        @add_module()
        class TestWithParams(object):
            def __init__(self, my_param):
                self.my_param = my_param

        test = Module.create("TestWithParams", my_param="foobar")
        self.assertIsInstance(test, TestWithParams)
        self.assertEqual(test.my_param, "foobar")
Exemple #4
0
    def __init__(self, training_name, data_path, training_results_path):
        super().__init__(training_name, data_path, training_results_path)
        # Config of the data
        self.data_dataset = FashionMNISTDataset

        # Config of the model
        self.model_model = lambda config: Module.create_from_file(
            "deeptech/examples/mnist_model.json",
            "MNISTModel",
            num_classes=10,
            logits=True)

        # Config for training
        self.training_loss = SparseCrossEntropyLossFromLogits
        self.training_optimizer = smart_optimizer(SGD)
        self.training_trainer = SupervisedTrainer
        self.training_epochs = 10
        self.training_batch_size = 32
    def __init__(self, training_name, data_path, training_results_path):
        super().__init__(training_name, data_path, training_results_path)
        # Config of the data
        self.data_dataset = lambda split: COCODataset(
            split, COCODataset.InputType, FasterRCNNOutput)
        self.data_version = 2014
        self.data_image_size = (800, 600)

        # Config of the model
        self.model_categories = []  # Fill from dataset.
        self.model_log_delta_preds = False
        self.model_model = lambda: Module.create(
            "FasterRCNN",
            num_classes=len(self.model_categories),
            log_deltas=self.model_log_delta_preds)

        # Config for training
        self.training_loss = self.create_loss
        self.training_optimizer = smart_optimizer(SGD, momentum=0.9)
        self.training_trainer = SupervisedTrainer
        self.training_epochs = 10
        self.training_batch_size = 1
        self.training_initial_lr = 0.001
 def setUp(self) -> None:
     add_lib_from_json("tests/json_nets/vgg16_bn.jsonc")
     self.module = Module.create("VGG16_bn", logits=True)
     self.input_data = torch.from_numpy(
         np.zeros((1, 128, 128, 3), dtype=np.float32))
     self.result = self.module(self.input_data)