_feed_forward
feed_forward
¶
Run a forward step on a given model.
This method can be used with TensorFlow models:
m = fe.architecture.tensorflow.LeNet(classes=2)
x = tf.ones((3,28,28,1)) # (batch, height, width, channels)
b = fe.backend.feed_forward(m, x) # [[~0.5, ~0.5], [~0.5, ~0.5], [~0.5, ~0.5]]
This method can be used with PyTorch models:
m = fe.architecture.pytorch.LeNet(classes=2)
x = torch.ones((3,1,28,28)) # (batch, channels, height, width)
b = fe.backend.feed_forward(m, x) # [[~0.5, ~0.5], [~0.5, ~0.5], [~0.5, ~0.5]]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Union[Model, Module]
|
A neural network to run the forward step through. |
required |
x |
Union[Tensor, ndarray]
|
One or more input tensor for the |
()
|
training |
bool
|
Whether this forward step is part of training or not. This may impact the behavior of |
True
|
Returns:
Type | Description |
---|---|
Tensor
|
The result of |
Raises:
Type | Description |
---|---|
ValueError
|
If |