Need to implement the most basic autoencoder (has only 1 hidden layer).
Code
This code is directly from the previous issue #4:
"""A simple autoencoder to get you started."""
from dataclasses import dataclass
from typing import Any
from typing import ClassVar
from typing import Dict
from typing import Optional
from keras import layers
from .base import BaseAutoencoder
from .base import BaseLayerParams
from .base import DefaultParams
@dataclass
class MinimalLayerParams(BaseLayerParams):
"""Layer parameters class for minimal autoencoder."""
# setup default values
default_parameters: ClassVar[DefaultParams] = {
"l0": (layers.InputLayer, {"input_shape": (784,)}),
"l1": (layers.Dense, {"units": 32, "activation": "relu"}),
"l2": (layers.Dense, {"units": 784, "activation": "sigmoid"}),
}
# setup instance layer params
l0: Optional[Dict[str, Any]] = None
l1: Optional[Dict[str, Any]] = None
l2: Optional[Dict[str, Any]] = None
class MinimalAutoencoder(BaseAutoencoder):
"""A simple autoencoder to get you started."""
_default_config = MinimalLayerParams()
def __init__(self, model_config: Optional[MinimalLayerParams] = None) -> None:
"""Overrided base constructor to set the layer params class used."""
# call super
super().__init__(model_config=model_config)
Problem
Need to implement the most basic autoencoder (has only 1 hidden layer).
Code
This code is directly from the previous issue #4:
References