예제 #1
0
    def test_tensor_scenario_type(self):
        n_experiences = 3
        test_data_x = [[torch.zeros(2, 3)], torch.zeros(2, 3)]
        test_data_y = [[torch.zeros(2)], torch.zeros(2)]

        for complete_test in [True, False]:
            for tdx, tdy in zip(test_data_x, test_data_y):
                try:                
                    tensor_scenario(
                        train_data_x=[torch.randn(2, 3)
                                      for _ in range(n_experiences)],
                        train_data_y=[torch.zeros(2)
                                      for _ in range(n_experiences)],
                        test_data_x=tdx,
                        test_data_y=tdy,
                        task_labels=[0]*n_experiences,
                        complete_test_set_only=complete_test)
                except ValueError:
                    if complete_test and \
                        not isinstance(tdx, torch.Tensor) and \
                            not isinstance(tdy, torch.Tensor):
                        print("Value Error raised correctly")
예제 #2
0
    "1": [13, 22, 20, 14, 6],
    "2": [9, 10, 0, 1, 2],
    "3": [11, 15, 17, 21],
    "4": [18, 19, 7, 8, 12],
    "5": [3, 4, 5, 16],
}

task_order_list = [perm]

dataset = task_ordering(task_order_list[0])

generic_scenario = tensor_scenario(
    train_data_x=dataset[0],
    train_data_y=dataset[1],
    test_data_x=dataset[2],
    test_data_y=dataset[3],
    task_labels=[
        0 for key in task_order_list[0].keys()
    ],  # shouldn't provide task ID for inference
)

# log to Tensorboard
tb_logger = TensorboardLogger(f"./tb_data/{cur_time}-SimpleMLP/")

# log to text file
text_logger = TextLogger(open(f"./logs/{cur_time}-SimpleMLP.txt", "w+"))

# print to stdout
interactive_logger = InteractiveLogger()

eval_plugin = EvaluationPlugin(
예제 #3
0

perm = {
    "1": [14, 9, 12, 15],
    "2": [4, 3, 5, 16],
    "3": [17, 11, 8],
    "4": [7, 6, 10, 18],
    "5": [2, 13, 1, 19],
}

dataset = task_ordering(perm)

generic_scenario = tensor_scenario(
    train_data_x=dataset[0],
    train_data_y=dataset[1],
    test_data_x=dataset[2],
    test_data_y=dataset[3],
    task_labels=[0 for key in perm.keys()],
)

# Model Creation
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = SimpleMLP(num_classes=2, input_size=70, hidden_size=100)

# log to Tensorboard
tb_logger = TensorboardLogger(f"./tb_data/{cur_time}-simpleMLP_Domain/")

# log to text file
text_logger = TextLogger(open(f"./logs/{cur_time}-simpleMLP_Domain.txt", "w+"))

# print to stdout