mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-14 11:26:24 +08:00
More type annotations
Summary: More type annotations: device, shaders, pluggable I/O, stats in NeRF project, cameras, textures, etc... Reviewed By: nikhilaravi Differential Revision: D29327396 fbshipit-source-id: cdf0ceaaa010e22423088752688c8dd81f1acc3c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
542e2e7c07
commit
f593bfd3c2
@@ -136,7 +136,7 @@ def download_data(
|
||||
dataset_names: Optional[List[str]] = None,
|
||||
data_root: str = DEFAULT_DATA_ROOT,
|
||||
url_root: str = DEFAULT_URL_ROOT,
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
Downloads the relevant dataset files.
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class AverageMeter:
|
||||
self.history = []
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
def reset(self) -> None:
|
||||
"""
|
||||
Reset the running average meter.
|
||||
"""
|
||||
@@ -38,7 +38,7 @@ class AverageMeter:
|
||||
self.sum = 0
|
||||
self.count = 0
|
||||
|
||||
def update(self, val: float, n: int = 1, epoch: int = 0):
|
||||
def update(self, val: float, n: int = 1, epoch: int = 0) -> None:
|
||||
"""
|
||||
Updates the average meter with a value `val`.
|
||||
|
||||
@@ -123,7 +123,7 @@ class Stats:
|
||||
self.plot_file = plot_file
|
||||
self.hard_reset(epoch=epoch)
|
||||
|
||||
def reset(self):
|
||||
def reset(self) -> None:
|
||||
"""
|
||||
Called before an epoch to clear current epoch buffers.
|
||||
"""
|
||||
@@ -138,7 +138,7 @@ class Stats:
|
||||
# Set a new timestamp.
|
||||
self._epoch_start = time.time()
|
||||
|
||||
def hard_reset(self, epoch: int = -1):
|
||||
def hard_reset(self, epoch: int = -1) -> None:
|
||||
"""
|
||||
Erases all logged data.
|
||||
"""
|
||||
@@ -149,7 +149,7 @@ class Stats:
|
||||
self.stats = {}
|
||||
self.reset()
|
||||
|
||||
def new_epoch(self):
|
||||
def new_epoch(self) -> None:
|
||||
"""
|
||||
Initializes a new epoch.
|
||||
"""
|
||||
@@ -166,7 +166,7 @@ class Stats:
|
||||
val = float(val.sum())
|
||||
return val
|
||||
|
||||
def update(self, preds: dict, stat_set: str = "train"):
|
||||
def update(self, preds: dict, stat_set: str = "train") -> None:
|
||||
"""
|
||||
Update the internal logs with metrics of a training step.
|
||||
|
||||
@@ -211,7 +211,7 @@ class Stats:
|
||||
if val is not None:
|
||||
self.stats[stat_set][stat].update(val, epoch=epoch, n=1)
|
||||
|
||||
def print(self, max_it: Optional[int] = None, stat_set: str = "train"):
|
||||
def print(self, max_it: Optional[int] = None, stat_set: str = "train") -> None:
|
||||
"""
|
||||
Print the current values of all stored stats.
|
||||
|
||||
@@ -247,7 +247,7 @@ class Stats:
|
||||
viz: Visdom = None,
|
||||
visdom_env: Optional[str] = None,
|
||||
plot_file: Optional[str] = None,
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
Plot the line charts of the history of the stats.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user