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

Method __init__

astroclip/modules.py:314–328  ·  view source on GitHub ↗
(
        self,
        weight: Union[torch.Tensor, nn.Parameter],
        bias: Union[None, torch.Tensor, nn.Parameter],
    )

Source from the content-addressed store, hash-verified

312 """size of each output sample."""
313
314 def __init__(
315 self,
316 weight: Union[torch.Tensor, nn.Parameter],
317 bias: Union[None, torch.Tensor, nn.Parameter],
318 ):
319 super().__init__()
320
321 if weight.ndim != 2:
322 raise ValueError(
323 f"weight parameter has {weight.ndim} dimensions, should have 2"
324 )
325 self.out_features, self.in_features = weight.shape
326
327 self.register_buffer("weight", weight)
328 self.register_buffer("bias", bias)
329
330 def forward(self, x: torch.Tensor) -> torch.Tensor:
331 return F.linear(x, self.weight, self.bias)

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected