netcnnbase
NetCNNBase
¶
Bases: LightningModule
Source code in spotpython/light/cnn/netcnnbase.py
8 9 10 11 12 13 14 15 16 17 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 44 45 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
__init__(model_name, model_hparams, optimizer_name, optimizer_hparams)
¶
Initializes the CNN model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name |
str
|
name of the model. |
required |
model_hparams |
dict
|
dictionary containing the hyperparameters for the model. |
required |
optimizer_name |
str
|
name of the optimizer. |
required |
optimizer_hparams |
dict
|
dictionary containing the hyperparameters for the optimizer. |
required |
Returns:
Type | Description |
---|---|
object
|
model object. |
Examples:
>>> from spotpython.light.cnn.netcnnbase import NetCNNBase
from spotpython.light.cnn.googlenet import GoogleNet
import torch
import torch.nn as nn
model_hparams = {"c_in": 3, "c_out": 10, "act_fn": nn.ReLU, "optimizer_name": "Adam"}
fun_control = {"core_model": GoogleNet}
model = NetCNNBase(model_hparams, fun_control)
x = torch.randn(1, 3, 32, 32)
y = model(x)
y.shape
torch.Size([1, 10])
Source code in spotpython/light/cnn/netcnnbase.py
9 10 11 12 13 14 15 16 17 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 44 45 46 47 48 |
|