Skip to content

Commit 3cdcfc5

Browse files
author
Fabrizio Romanelli
committed
Adding annotations to DAE class and methods
1 parent 552a866 commit 3cdcfc5

File tree

1 file changed

+166
-15
lines changed

1 file changed

+166
-15
lines changed

src/deepforge/dae.py

Lines changed: 166 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,217 @@
88
from keras.models import Model
99

1010
class DAE(DNN):
11-
"""Denoising AutoEncoder class"""
11+
"""
12+
This class implements the Denoising Auto-Encoder model.
13+
14+
Attributes
15+
----------
16+
__encLayersArgs : list
17+
List of arguments for the encoder layer.
18+
__hidLayersArgs : list
19+
List of arguments for the hidden layers.
20+
__decLayersArgs : list
21+
List of arguments for the decoder layers.
22+
__modelParams : dict
23+
Dictionary containing the parameters to be passed to the model for its compilation.
24+
25+
Methods
26+
-------
27+
setEncoderLayer(layersArgs: list)
28+
Set the encoder layer arguments for the DAE.
29+
getEncoderLayer()
30+
Get the encoder layer arguments for the DAE.
31+
setHiddenLayers(layersArgs: list)
32+
Set the hidden layer arguments for the DAE.
33+
getHiddenLayers()
34+
Get the hidden layer arguments for the DAE.
35+
setDecoderLayer(layersArgs: list)
36+
Set the decoder layer arguments for the DAE.
37+
getDecoderLayer()
38+
Get the decoder layer arguments for the DAE.
39+
setModelConfiguration(modelParams: dict)
40+
Set the parameters for the DAE model (used for its compilation).
41+
getModelConfiguration()
42+
Get the parameters of the DAE model (used for its compilation).
43+
build()
44+
Build the model.
45+
"""
1246

13-
# Constructor
1447
def __init__(self, name: str, inputN: int=1) -> None:
1548
super().__init__(name,inputN)
1649
self.__encLayersArgs: list = []
1750
self.__hidLayersArgs: list = []
1851
self.__decLayersArgs: list = []
1952
self.__modelParams: dict=None
2053

21-
# Setter and getter for encoder Layer arguments
2254
def setEncoderLayer(self, layersArgs: list) -> None:
55+
'''
56+
This method is used to set the encoder layers of the DAE model.
57+
58+
Parameters
59+
----------
60+
layersArgs : list
61+
The arguments for the encoder layers.
62+
63+
Returns
64+
-------
65+
None
66+
'''
2367
self.__encLayersArgs = layersArgs
2468
return
2569

2670
def getEncoderLayer(self) -> list:
71+
'''
72+
This method is used to get the encoder layers of the DAE model.
73+
74+
Parameters
75+
----------
76+
None
77+
78+
Raises
79+
------
80+
ValueError:
81+
If the model has no encoder layers arguments set yet.
82+
83+
Returns
84+
-------
85+
list :
86+
The list of encoder layers arguments.
87+
'''
2788
if self.__encLayersArgs is not []:
2889
return self.__encLayersArgs
2990
else:
30-
print('[DF] Model has no layers arguments set yet.')
31-
return
91+
raise ValueError('[DF] Model has no layers arguments set yet.')
3292

33-
# Setter and getter for hidden Layer arguments
3493
def setHiddenLayers(self, layersArgs: list) -> None:
94+
'''
95+
This method is used to set the hidden layers of the DAE model.
96+
97+
Parameters
98+
----------
99+
layersArgs : list
100+
The arguments for the hidden layers.
101+
102+
Returns
103+
-------
104+
None
105+
'''
35106
self.__hidLayersArgs = layersArgs
36107
return
37108

38109
def getHiddenLayers(self) -> list:
110+
'''
111+
This method is used to get the hidden layers of the DAE model.
112+
113+
Parameters
114+
----------
115+
None
116+
117+
Raises
118+
------
119+
ValueError:
120+
If the model has no hidden layers arguments set yet.
121+
122+
Returns
123+
-------
124+
list :
125+
The list of hidden layers arguments.
126+
'''
39127
if self.__hidLayersArgs is not []:
40128
return self.__hidLayersArgs
41129
else:
42-
print('[DF] Model has no layers arguments set yet.')
43-
return
130+
raise ValueError('[DF] Model has no layers arguments set yet.')
44131

45-
# Setter and getter for decoder Layer arguments
46132
def setDecoderLayer(self, layersArgs: list) -> None:
133+
'''
134+
This method is used to set the decoder layers of the DAE model.
135+
136+
Parameters
137+
----------
138+
layersArgs : list
139+
The arguments for the decoder layers.
140+
141+
Returns
142+
-------
143+
None
144+
'''
47145
self.__decLayersArgs = layersArgs
48146
return
49147

50148
def getDecoderLayer(self) -> list:
149+
'''
150+
This method is used to get the decoder layers of the DAE model.
151+
152+
Parameters
153+
----------
154+
None
155+
156+
Raises
157+
------
158+
ValueError:
159+
If the model has no decoder layers arguments set yet.
160+
161+
Returns
162+
-------
163+
list :
164+
The list of decoder layers arguments.
165+
'''
51166
if self.__decLayersArgs is not []:
52167
return self.__decLayersArgs
53168
else:
54-
print('[DF] Model has no layers arguments set yet.')
55-
return
169+
raise ValueError('[DF] Model has no layers arguments set yet.')
56170

57-
# Setter and getter for model configuration
58171
def setModelConfiguration(self, **modelParams: dict) -> None:
172+
'''
173+
This method is used to set the model configuration for the DAE model.
174+
175+
Parameters
176+
----------
177+
modelParams : dict
178+
The model parameters used in the training/fit phase.
179+
180+
Returns
181+
-------
182+
None
183+
'''
59184
self.__modelParams = modelParams
60185
return
61186

62187
def getModelConfiguration(self) -> dict:
188+
'''
189+
This method is used to get the model configuration for the DAE model.
190+
191+
Parameters
192+
----------
193+
None
194+
195+
Raises
196+
------
197+
ValueError:
198+
If the model has no configuration arguments set yet.
199+
200+
Returns
201+
-------
202+
dict :
203+
The dictionary of the model parameters.
204+
'''
63205
if self.__modelParams is not None:
64206
return self.__modelParams
65207
else:
66-
print('[DF] Model has no configuration arguments set yet.')
67-
return
208+
raise ValueError('[DF] Model has no configuration arguments set yet.')
68209

69-
# Build model
70210
def build(self) -> None:
211+
'''
212+
This method is used to build the model for the DAE model.
213+
214+
Parameters
215+
----------
216+
None
217+
218+
Returns
219+
-------
220+
None
221+
'''
71222
print("[DF] Building model...")
72223

73224
# Build encoder layer

0 commit comments

Comments
 (0)