MCPcopy Create free account
hub / github.com/PolymathicAI/AstroCLIP / _slice

Method _slice

astroclip/models/specformer.py:138–153  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

136 self.head.apply(lambda m: _init_by_depth(m, 1 / 2))
137
138 def _slice(self, x):
139 start_indices = np.arange(
140 0,
141 x.shape[1] - self.hparams.slice_overlap,
142 self.hparams.slice_section_length - self.hparams.slice_overlap,
143 )
144 sections = [
145 x[:, start : start + self.hparams.slice_section_length].transpose(1, 2)
146 for start in start_indices
147 ]
148
149 # If the last section is not of length 'section_length', you can decide whether to keep or discard it
150 if sections[-1].shape[1] < self.hparams.slice_section_length:
151 sections.pop(-1) # Discard the last section
152
153 return torch.cat(sections, 1)
154
155 def _mask_seq(self, seq: torch.Tensor) -> torch.Tensor:
156 """Randomly masks contiguous sections of an unbatched sequence,

Callers 1

preprocessMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected