MCPcopy Create free account
hub / github.com/ElliotVincent/SitsSCD / setup

Method setup

data/datamodule.py:38–59  ·  view source on GitHub ↗

Setup the datamodule. Args: stage (str): stage of the datamodule Is be one of "fit" or "test" or None

(self, stage=None)

Source from the content-addressed store, hash-verified

36 return self._builders["train"]().num_classes
37
38 def setup(self, stage=None):
39 """Setup the datamodule.
40 Args:
41 stage (str): stage of the datamodule
42 Is be one of "fit" or "test" or None
43 """
44 print("Stage", stage)
45 start_time = time.time()
46 if stage == "fit" or stage is None:
47 self.train_dataset = self._builders["train"]()
48 self.val_dataset_out = self._builders["val_out"]()
49 self.val_dataset_in = self._builders["val_in"]()
50 print(f"Train dataset size: {len(self.train_dataset)}")
51 print(f"Out-of-domain val dataset size: {len(self.val_dataset_out)}")
52 print(f"In-domain val dataset size: {len(self.val_dataset_in)}")
53 else:
54 self.test_dataset_out = self._builders["test_out"]()
55 self.test_dataset_in = self._builders["test_in"]()
56 print(f"Out-of-domain test dataset size: {len(self.test_dataset_out)}")
57 print(f"In-domain test dataset size: {len(self.test_dataset_in)}")
58 end_time = time.time()
59 print(f"Setup took {(end_time - start_time):.2f} seconds")
60
61 def train_dataloader(self):
62 return DataLoader(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected