How to expand dims of my Keras layer and avoid using Lambda layerKeras: Use the same layer in different models (share weights)Unable to understand how lambda layer work in keras?Keras Lambda Layer giving ValueError: None values not supported when trying to fit modelWrap tensorflow function in keras layerHow to load MobileNet weights with an input tensor in KerasHow to Build a 2D Weights Matrix in Keras?Multiple Embedding layers for Keras Sequential modelValueError: Output tensors to a Model must be the output of a TensorFlow Layer with tf.keras Lambda layerThe initial state or constants of an RNN layer cannot be specified with a mix of Keras tensors and non-Keras tensors3 dimensional array as input with Embedding Layer and LSTM in Keras
How to re-create Edward Weson's Pepper No. 30?
Why is the design of haulage companies so “special”?
Representing power series as a function - what to do with the constant after integration?
Theorems that impeded progress
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Today is the Center
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Why Is Death Allowed In the Matrix?
What is the offset in a seaplane's hull?
XeLaTeX and pdfLaTeX ignore hyphenation
"You are your self first supporter", a more proper way to say it
A function which translates a sentence to title-case
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?
Motorized valve interfering with button?
Python: Add Submenu
What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?
"which" command doesn't work / path of Safari?
Download, install and reboot computer at night if needed
How to add power-LED to my small amplifier?
How to report a triplet of septets in NMR tabulation?
Copenhagen passport control - US citizen
Why don't electron-positron collisions release infinite energy?
How to expand dims of my Keras layer and avoid using Lambda layer
Keras: Use the same layer in different models (share weights)Unable to understand how lambda layer work in keras?Keras Lambda Layer giving ValueError: None values not supported when trying to fit modelWrap tensorflow function in keras layerHow to load MobileNet weights with an input tensor in KerasHow to Build a 2D Weights Matrix in Keras?Multiple Embedding layers for Keras Sequential modelValueError: Output tensors to a Model must be the output of a TensorFlow Layer with tf.keras Lambda layerThe initial state or constants of an RNN layer cannot be specified with a mix of Keras tensors and non-Keras tensors3 dimensional array as input with Embedding Layer and LSTM in Keras
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I' m using tensorflow.js and try to convert my keras model to tf.js model. However, it doesn't support Lambda layer which I try to use to convert tensorto layer(I use expand_dims) in my model(If not use it, model won't be created correctly, you know the reason). So I wonder if there is any way that I can avoid using Lambda layer and expand the dim of my embedding_layer.
# input layer
input_x = Input(shape=(sequence_length, ), dtype='int32')
# embedding layer
embedding_layer = Embedding(vocab_size,
embedding_size,
embeddings_initializer=random_uniform(minval=-1.0, maxval=1.0))(input_x)
embedded_sequences = Lambda(lambda x: expand_dims(x, -1))(embedding_layer)
I'll appreciate it if you could give me some help, thanks!
tensorflow keras
add a comment |
I' m using tensorflow.js and try to convert my keras model to tf.js model. However, it doesn't support Lambda layer which I try to use to convert tensorto layer(I use expand_dims) in my model(If not use it, model won't be created correctly, you know the reason). So I wonder if there is any way that I can avoid using Lambda layer and expand the dim of my embedding_layer.
# input layer
input_x = Input(shape=(sequence_length, ), dtype='int32')
# embedding layer
embedding_layer = Embedding(vocab_size,
embedding_size,
embeddings_initializer=random_uniform(minval=-1.0, maxval=1.0))(input_x)
embedded_sequences = Lambda(lambda x: expand_dims(x, -1))(embedding_layer)
I'll appreciate it if you could give me some help, thanks!
tensorflow keras
js.tensorflow.org/api/0.15.3/#expandDims
– Manoj Mohan
Mar 22 at 1:24
But my model is converted from Keras, so I can't expand dim of the model in js, it's fixed in "model.json".
– Jackie Swocky
Mar 22 at 2:28
add a comment |
I' m using tensorflow.js and try to convert my keras model to tf.js model. However, it doesn't support Lambda layer which I try to use to convert tensorto layer(I use expand_dims) in my model(If not use it, model won't be created correctly, you know the reason). So I wonder if there is any way that I can avoid using Lambda layer and expand the dim of my embedding_layer.
# input layer
input_x = Input(shape=(sequence_length, ), dtype='int32')
# embedding layer
embedding_layer = Embedding(vocab_size,
embedding_size,
embeddings_initializer=random_uniform(minval=-1.0, maxval=1.0))(input_x)
embedded_sequences = Lambda(lambda x: expand_dims(x, -1))(embedding_layer)
I'll appreciate it if you could give me some help, thanks!
tensorflow keras
I' m using tensorflow.js and try to convert my keras model to tf.js model. However, it doesn't support Lambda layer which I try to use to convert tensorto layer(I use expand_dims) in my model(If not use it, model won't be created correctly, you know the reason). So I wonder if there is any way that I can avoid using Lambda layer and expand the dim of my embedding_layer.
# input layer
input_x = Input(shape=(sequence_length, ), dtype='int32')
# embedding layer
embedding_layer = Embedding(vocab_size,
embedding_size,
embeddings_initializer=random_uniform(minval=-1.0, maxval=1.0))(input_x)
embedded_sequences = Lambda(lambda x: expand_dims(x, -1))(embedding_layer)
I'll appreciate it if you could give me some help, thanks!
tensorflow keras
tensorflow keras
asked Mar 22 at 0:43
Jackie SwockyJackie Swocky
133
133
js.tensorflow.org/api/0.15.3/#expandDims
– Manoj Mohan
Mar 22 at 1:24
But my model is converted from Keras, so I can't expand dim of the model in js, it's fixed in "model.json".
– Jackie Swocky
Mar 22 at 2:28
add a comment |
js.tensorflow.org/api/0.15.3/#expandDims
– Manoj Mohan
Mar 22 at 1:24
But my model is converted from Keras, so I can't expand dim of the model in js, it's fixed in "model.json".
– Jackie Swocky
Mar 22 at 2:28
js.tensorflow.org/api/0.15.3/#expandDims
– Manoj Mohan
Mar 22 at 1:24
js.tensorflow.org/api/0.15.3/#expandDims
– Manoj Mohan
Mar 22 at 1:24
But my model is converted from Keras, so I can't expand dim of the model in js, it's fixed in "model.json".
– Jackie Swocky
Mar 22 at 2:28
But my model is converted from Keras, so I can't expand dim of the model in js, it's fixed in "model.json".
– Jackie Swocky
Mar 22 at 2:28
add a comment |
1 Answer
1
active
oldest
votes
I solved it by myself.
Just use reshape.
from keras.backend import int_shape
......
embedded_sequences = Reshape((int_shape(embedding_layer)[1], int_shape(embedding_layer)[2], 1))(embedding_layer)
......
You could expand dim without using expand_dims and Lambda layer.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291277%2fhow-to-expand-dims-of-my-keras-layer-and-avoid-using-lambda-layer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I solved it by myself.
Just use reshape.
from keras.backend import int_shape
......
embedded_sequences = Reshape((int_shape(embedding_layer)[1], int_shape(embedding_layer)[2], 1))(embedding_layer)
......
You could expand dim without using expand_dims and Lambda layer.
add a comment |
I solved it by myself.
Just use reshape.
from keras.backend import int_shape
......
embedded_sequences = Reshape((int_shape(embedding_layer)[1], int_shape(embedding_layer)[2], 1))(embedding_layer)
......
You could expand dim without using expand_dims and Lambda layer.
add a comment |
I solved it by myself.
Just use reshape.
from keras.backend import int_shape
......
embedded_sequences = Reshape((int_shape(embedding_layer)[1], int_shape(embedding_layer)[2], 1))(embedding_layer)
......
You could expand dim without using expand_dims and Lambda layer.
I solved it by myself.
Just use reshape.
from keras.backend import int_shape
......
embedded_sequences = Reshape((int_shape(embedding_layer)[1], int_shape(embedding_layer)[2], 1))(embedding_layer)
......
You could expand dim without using expand_dims and Lambda layer.
answered Mar 22 at 4:06
Jackie SwockyJackie Swocky
133
133
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291277%2fhow-to-expand-dims-of-my-keras-layer-and-avoid-using-lambda-layer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
js.tensorflow.org/api/0.15.3/#expandDims
– Manoj Mohan
Mar 22 at 1:24
But my model is converted from Keras, so I can't expand dim of the model in js, it's fixed in "model.json".
– Jackie Swocky
Mar 22 at 2:28