• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

f-dangel / backpack / 8116261751

01 Mar 2024 07:30PM UTC coverage: 98.375%. Remained the same
8116261751

Pull #323

github

web-flow
Merge 610195223 into e9b1dd361
Pull Request #323: [FIX | FMT] RTD build, apply latest `black` and `isort`

97 of 97 new or added lines in 97 files covered. (100.0%)

43 existing lines in 18 files now uncovered.

4420 of 4493 relevant lines covered (98.38%)

11.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/backpack/custom_module/scale_module.py
1
"""Contains ScaleModule."""
2
from torch import Tensor
12✔
3
from torch.nn import Module
12✔
4

5

6
class ScaleModule(Module):
12✔
7
    """Scale Module scales the input by a constant."""
8

9
    def __init__(self, weight: float = 1.0):
12✔
10
        """Store scalar weight.
11

12
        Args:
13
            weight: Initial value for weight. Defaults to 1.0.
14

15
        Raises:
16
            ValueError: if weight is no float
17
        """
18
        super().__init__()
12✔
19
        if not isinstance(weight, float):
12✔
UNCOV
20
            raise ValueError("Weight must be float.")
×
21
        self.weight: float = weight
12✔
22

23
    def forward(self, input: Tensor) -> Tensor:
12✔
24
        """Defines forward pass.
25

26
        Args:
27
            input: input
28

29
        Returns:
30
            product of input and weight
31
        """
32
        return input * self.weight
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc