Skip to content

Commit 3f630d8

Browse files
GiovanniCanalidario-coscia
authored andcommitted
fix optim doc
1 parent 3374176 commit 3f630d8

File tree

5 files changed

+37
-38
lines changed

5 files changed

+37
-38
lines changed

pina/optim/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module for Optimizer class."""
1+
"""Module for the Optimizers and Schedulers."""
22

33
__all__ = [
44
"Optimizer",

pina/optim/optimizer_interface.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
"""Module for PINA Optimizer."""
1+
"""Module for the PINA Optimizer."""
22

33
from abc import ABCMeta, abstractmethod
44

55

66
class Optimizer(metaclass=ABCMeta):
77
"""
8-
TODO
9-
:param metaclass: _description_, defaults to ABCMeta
10-
:type metaclass: _type_, optional
8+
Abstract base class for defining an optimizer. All specific optimizers
9+
should inherit form this class and implement the required methods.
1110
"""
1211

1312
@property
1413
@abstractmethod
1514
def instance(self):
1615
"""
17-
TODO
16+
Abstract property to retrieve the optimizer instance.
1817
"""
1918

2019
@abstractmethod
2120
def hook(self):
2221
"""
23-
TODO
22+
Abstract method to define the hook logic for the optimizer.
2423
"""

pina/optim/scheduler_interface.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
"""Module for PINA Scheduler."""
1+
"""Module for the PINA Scheduler."""
22

33
from abc import ABCMeta, abstractmethod
44

55

66
class Scheduler(metaclass=ABCMeta):
77
"""
8-
TODO
9-
10-
:param metaclass: _description_, defaults to ABCMeta
11-
:type metaclass: _type_, optional
8+
Abstract base class for defining a scheduler. All specific schedulers should
9+
inherit form this class and implement the required methods.
1210
"""
1311

1412
@property
1513
@abstractmethod
1614
def instance(self):
1715
"""
18-
TODO
16+
Abstract property to retrieve the scheduler instance.
1917
"""
2018

2119
@abstractmethod
2220
def hook(self):
2321
"""
24-
TODO
22+
Abstract method to define the hook logic for the scheduler.
2523
"""

pina/optim/torch_optimizer.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module for PINA Torch Optimizer"""
1+
"""Module for the PINA Torch Optimizer"""
22

33
import torch
44

@@ -8,18 +8,17 @@
88

99
class TorchOptimizer(Optimizer):
1010
"""
11-
TODO
12-
13-
:param Optimizer: _description_
14-
:type Optimizer: _type_
11+
A wrapper class for using PyTorch optimizers.
1512
"""
1613

1714
def __init__(self, optimizer_class, **kwargs):
1815
"""
19-
TODO
16+
Initialization of the :class:`TorchOptimizer` class.
2017
21-
:param optimizer_class: _description_
22-
:type optimizer_class: _type_
18+
:param torch.optim.Optimizer optimizer_class: The PyTorch optimizer
19+
class.
20+
:param dict kwargs: Additional parameters passed to `optimizer_class`,
21+
see more: <https://pytorch.org/docs/stable/optim.html#algorithms>_.
2322
"""
2423
check_consistency(optimizer_class, torch.optim.Optimizer, subclass=True)
2524

@@ -29,10 +28,9 @@ def __init__(self, optimizer_class, **kwargs):
2928

3029
def hook(self, parameters):
3130
"""
32-
TODO
31+
Initialize the optimizer instance with the given parameters.
3332
34-
:param parameters: _description_
35-
:type parameters: _type_
33+
:param dict parameters: The parameters of the model to be optimized.
3634
"""
3735
self._optimizer_instance = self.optimizer_class(
3836
parameters, **self.kwargs
@@ -41,6 +39,9 @@ def hook(self, parameters):
4139
@property
4240
def instance(self):
4341
"""
44-
Optimizer instance.
42+
Get the optimizer instance.
43+
44+
:return: The optimizer instance.
45+
:rtype: torch.optim.Optimizer
4546
"""
4647
return self._optimizer_instance

pina/optim/torch_scheduler.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module for PINA Torch Optimizer"""
1+
"""Module for the PINA Torch Optimizer"""
22

33
try:
44
from torch.optim.lr_scheduler import LRScheduler # torch >= 2.0
@@ -14,18 +14,17 @@
1414

1515
class TorchScheduler(Scheduler):
1616
"""
17-
TODO
18-
19-
:param Scheduler: _description_
20-
:type Scheduler: _type_
17+
A wrapper class for using PyTorch schedulers.
2118
"""
2219

2320
def __init__(self, scheduler_class, **kwargs):
2421
"""
25-
TODO
22+
Initialization of the :class:`TorchScheduler` class.
2623
27-
:param scheduler_class: _description_
28-
:type scheduler_class: _type_
24+
:param torch.optim.LRScheduler scheduler_class: The PyTorch scheduler
25+
class.
26+
:param dict kwargs: Additional parameters passed to `scheduler_class`,
27+
see more: <https://pytorch.org/docs/stable/optim.html#algorithms>_.
2928
"""
3029
check_consistency(scheduler_class, LRScheduler, subclass=True)
3130

@@ -35,10 +34,9 @@ def __init__(self, scheduler_class, **kwargs):
3534

3635
def hook(self, optimizer):
3736
"""
38-
TODO
37+
Initialize the scheduler instance with the given parameters.
3938
40-
:param optimizer: _description_
41-
:type optimizer: _type_
39+
:param dict parameters: The parameters of the optimizer.
4240
"""
4341
check_consistency(optimizer, Optimizer)
4442
self._scheduler_instance = self.scheduler_class(
@@ -48,6 +46,9 @@ def hook(self, optimizer):
4846
@property
4947
def instance(self):
5048
"""
51-
Scheduler instance.
49+
Get the scheduler instance.
50+
51+
:return: The scheduelr instance.
52+
:rtype: torch.optim.LRScheduler
5253
"""
5354
return self._scheduler_instance

0 commit comments

Comments
 (0)