Lambda output layer
See original GitHub issueI’ve a sequential model as follows with a linear activation function (Keras default) for the single output neuron:
model = Sequential()
model.add( ...
...
model.add(Dense(100, activation='relu'))
model.add(Dense(1))
I need the final number to be bounded by 100, so I modified the last line of code above to be:
model.add(Lambda(lambda x: x%100, output_shape=(1)))
1- Is it correct? Does x here means the net as I expect ?
2- I get an error: “In Lambda, output_shape must be a list, a tuple, or a function”.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Using layers with your Lambda function - AWS Documentation
A Lambda layer is a .zip file archive that can contain additional code or other content. A layer can contain libraries, a custom...
Read more >Lambda layer - Keras
The Lambda layer exists so that arbitrary expressions can be used as a Layer when constructing Sequential and Functional API models. Lambda layers...
Read more >Working With The Lambda Layer in Keras - Paperspace Blog
In this tutorial we'll cover how to use the Lambda layer in Keras to build, save and load models which perform custom operations...
Read more >How to Use Lambda Layer in a Neural Network?
the lambda layer is a layer for neural network that helps in the data transformation between the other layers of a neural network....
Read more >Lambda Layers in tf.keras - Medium
Lambda layer is an easy way to customize a layer to do simple… ... the output from the previous layer as input and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
(Notice the comma after 1)
You can also igonre the
output_shape
argument in this case.For bounding by 100, I think you should use K.clip.
For an example of a function that takes an arbitrary-shape tensor and outputs a scalar, see
K.sum()
.