HubAndSpokes
Bases: tf.keras.Model
__init__(tau, hub_name, hub_units, spoke_names, spoke_units)
Hub-and-spokes model.
See Rogers et. al., 2004 for more details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tau |
float
|
Time constant of the time-averaging. |
required |
hub_name |
str
|
Name of the hub layer. |
required |
hub_units |
int
|
Number of units in the hub layer. |
required |
spoke_names |
List[str]
|
Names of the spoke layers. |
required |
spoke_units |
List[int]
|
Number of units in each spoke layer. Must be the same length as |
required |
call(inputs, return_internals=False)
Forward pass.
The number of time steps is determined by axis 1 in the inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs |
Dict[str, tf.Tensor]
|
Inputs to the spokes (name as key). Assumes input is 0 if not given. |
required |
return_internals |
bool
|
Whether to return intermediate inputs to each connection. |
False
|
Returns:
| Type | Description |
|---|---|
Dict[str, tf.Tensor]
|
Dict[str, tf.Tensor]: Activations of the hub and spokes, with layer names as keys.
If |
train_step(data)
Train the model for one step.
Loss is cumulated over all y_train items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data |
Tuple[Dict[str, tf.Tensor]]
|
Tuple of (x_train, y_train). |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, tf.Tensor]
|
Dict[str, tf.Tensor]: metrics. |