Networks
mighty.mighty_models.networks
#
Networks architectures for feature extraction.
CNN
#
CNN(
obs_shape,
n_convolutions,
out_channels,
sizes,
strides,
paddings,
activation="relu",
flatten=True,
conv_dim=None,
)
Bases: ScriptModule
CNN network.
Source code in mighty/mighty_models/networks.py
ComboNet
#
Bases: ScriptModule
Combination of several network architectures network.
Source code in mighty/mighty_models/networks.py
MLP
#
Bases: ScriptModule
MLP network.
Source code in mighty/mighty_models/networks.py
forward
#
full_hard_reset
#
reset
#
soft_reset
#
Soft reset of the network.
Source code in mighty/mighty_models/networks.py
ResNet
#
Bases: ScriptModule
ResNet with 3 layers network.
Source code in mighty/mighty_models/networks.py
ResNetBlock
#
Bases: ScriptModule
Single ResNet block.
Source code in mighty/mighty_models/networks.py
ResNetLayer
#
Bases: ScriptModule
Single ResNet layer.
Source code in mighty/mighty_models/networks.py
make_feature_extractor
#
make_feature_extractor(
architecture="mlp",
n_layers=3,
hidden_sizes=None,
activation="relu",
obs_shape=None,
n_convolutions=3,
out_channels=None,
sizes=None,
strides=None,
paddings=None,
flatten_cnn=True,
conv_dim=None,
planes=None,
model_name: str = "resnet18",
repo: str = "pytorch/vision:v0.9.0",
pretrained: bool = False,
)
Construct a feature extractor module based on the specified architecture.
PARAMETER | DESCRIPTION |
---|---|
architecture
|
Type of architecture to use. Options include: 'mlp', 'cnn', 'resnet', 'torchhub', or a list of such architectures for a ComboNet. |
n_layers
|
Number of layers (for MLP).
TYPE:
|
hidden_sizes
|
Hidden layer sizes for MLP. Defaults to [32, 32, 32]. |
activation
|
Activation function to use (e.g., 'relu').
TYPE:
|
obs_shape
|
Shape of the input observations (e.g., (3, 64, 64)).
TYPE:
|
n_convolutions
|
Number of convolutional layers (for CNN).
TYPE:
|
out_channels
|
Number of output channels per conv layer. Defaults to [32, 64, 64]. |
sizes
|
Kernel sizes for conv layers. Defaults to [8, 4, 3]. |
strides
|
Stride values for conv layers. Optional. |
paddings
|
Padding values for conv layers. Optional. |
flatten_cnn
|
Whether to flatten CNN output. Default is True.
TYPE:
|
conv_dim
|
Optional override for CNN output dimension.
TYPE:
|
planes
|
List of feature planes (channels) for ResNet. Defaults to [16, 32, 32]. |
model_name
|
Model name to use with torch.hub (e.g., 'resnet18').
TYPE:
|
repo
|
TorchHub repo string, e.g., 'pytorch/vision:v0.9.0'.
TYPE:
|
pretrained
|
Whether to use pretrained weights for torchhub models.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
fe
|
The constructed feature extractor network. output_size (list[int]): Shape of the feature output (excluding batch dimension).
TYPE:
|
Source code in mighty/mighty_models/networks.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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|