Helper functions
VAE.utils.collection
Collection of helper functions.
VAE.utils.collection.TrainerConfigCollection
TrainerConfigCollection(path='.', filemask='*.yaml', recursive=True, verbose=True)
Parameters:
-
path
(str
, default:'.'
) –Path to the training configuration files. Defaults to
.
. -
filemask
(str
, default:'*.yaml'
) –Filename or filemask of the training configuration files. Defaults to
*.yaml
. -
recursive
(bool
, default:True
) –Recursive search in subdirectories. Defaults to True.
-
verbose
(bool
, default:True
) –Verbose output. Defaults to True.
Source code in VAE/utils/collection.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
VAE.utils.collection.TrainerConfigCollection.__getitem__
__getitem__(key)
Get configurations for a given key.
Parameters:
-
key
–str Key of the training configuration. For example 'fit_generator' or 'model'. For a list of keys see :func:
keys
.
Returns:
-
dict
–Dictionary of configuration parameters for the given key.
Source code in VAE/utils/collection.py
182 183 184 185 186 187 188 189 190 191 192 193 |
|
VAE.utils.collection.TrainerConfigCollection.__read__
__read__()
Read the configuration files.
Source code in VAE/utils/collection.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
VAE.utils.collection.TrainerConfigCollection.keys
keys()
Return list of keys.
Returns:
-
–
dictitems
Source code in VAE/utils/collection.py
222 223 224 225 226 227 228 |
|
VAE.utils.collection.TrainerConfigCollection.to_dataframe
to_dataframe(key, fillna='')
Convert configurations to dataframe.
Parameters:
-
key
–str Key of the training configuration.
-
fillna
–str, optional Fill value for missing values. Defaults to ''.
Returns:
-
–
pd.DataFrame
Source code in VAE/utils/collection.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
VAE.utils.collection.TrainerConfigCollection.to_excel
to_excel(filename, key=None, fillna='', column_width=None)
Write configurations to excel file.
Parameters:
-
filename
–str Filename of excel file to write.
-
key
–str, optional Key of the training configuration(s) to write, defaults to None, i.e. write all configurations.
-
fillna
–str, optional Fill value for missing values, defaults to ''.
-
column_width
–float, optional Fixed column width, defaults to None.
Source code in VAE/utils/collection.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
VAE.utils.collection.complete_shape
complete_shape(inputs, partial_shape)
Complete partially-known shape based on inputs shape.
Input shape of inputs
must be of the same length as partial_shape
. None
values in partial_shape
will be
replaced with the corresponding dimension of inputs
. The resulting shape is returned as a tensor of the same
length as the shape of inputs
.
Parameters:
-
inputs
(Tensor
) –Input tensor that is used to complete shape.
-
partial_shape
(tuple[int, ...]
) –Partial shape to complete.
Returns:
-
Tensor
–Tensor with completed shape.
Source code in VAE/utils/collection.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
VAE.utils.collection.summary_trainable
summary_trainable(model, line_length=80)
Print model summary of trainable parameters.
This function prints a summary of trainable layers of a model.
Parameters:
-
model
(Model
) –Model to be summarized.
-
line_length
(int
, default:80
) –Total length of each printed line.
Source code in VAE/utils/collection.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
VAE.utils.collection.set_trainable
set_trainable(model, trainable, verbose=False)
Set trainable layers of a Keras model.
This function sets the trainable property of layers of a Keras model. The layers to be set trainable can be defined by their name. Unix shell-style wildcards can be used. If a layer is set to trainable, all its children will be set to trainable as well.
Parameters:
-
model
(Model
) –Model to be modified.
-
trainable
(Union[str, List[str]]
) –Layer names to be set to trainable. Unix shell-style wildcards can be used.
-
verbose
(bool
, default:False
) –Print the names of the layers that are set to trainable if
True
.
Source code in VAE/utils/collection.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
VAE.utils.collection.SubModel
SubModel(model, layer_name, flatten=False)
Get a submodel of a Keras model.
This function returns a submodel of a Keras model. The submodel takes the same input as the original model, and covers all layers of the original model between the input layer and the layer(s) with the specified name.
Parameters:
-
model
(Model
) –Model to be submodeled.
-
layer_name
(Union[str, list[str]]
) –If str, it specifies the name of the layer to be used as output. In this case,
layer_name
can be a substring of the layer name. If list of str, it specifies the names of the layers to be used as outputs. -
flatten
(bool
, default:False
) –If True, the outputs of the submodel are flattened.
Returns:
Instance of :class:keras.Model
.
Source code in VAE/utils/collection.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|