Weird layer suffix issue running in Jupyter Notebook2019 Community Moderator ElectionKeras - All layer names should be uniquewrap a general python function in tensorflowError when checking model target: expected dense_2 to have shape (None, 29430) but got array with shape (1108, 1)Getting the output of layer as a feature vector (KERAS)Keras Sequential model input layerWhat is the role of TimeDistributed layer in Keras?How does Keras read input data?Keras Model - Functional API - adding layers to existing modelKerras the definition of a model changes when the input tensor of the model is the output of another modelUse Glove vectors without Embedding layers in LSTMKeras functional api gives error “expected ndim=3, found ndim=4”
Relationship between sampajanna definitions in SN 47.2 and SN 47.35
How could an airship be repaired midflight?
A diagram about partial derivatives of f(x,y)
Is there a symmetric-key algorithm which we can use for creating a signature?
Bacteria contamination inside a thermos bottle
Knife as defense against stray dogs
What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?
Non-trivial topology where only open sets are closed
What is the adequate fee for a reveal operation?
Could the Saturn V actually have launched astronauts around Venus?
Print a physical multiplication table
Are ETF trackers fundamentally better than individual stocks?
Do I need life insurance if I can cover my own funeral costs?
Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?
How could a scammer know the apps on my phone / iTunes account?
When to use a slotted vs. solid turner?
Why is a white electrical wire connected to 2 black wires?
Why did it take so long to abandon sail after steamships were demonstrated?
Is it good practice to use Linear Least-Squares with SMA?
Is Manda another name for Saturn (Shani)?
What is the relationship between relativity and the Doppler effect?
How to make healing in an exploration game interesting
Do I need to be arrogant to get ahead?
English sentence unclear
Weird layer suffix issue running in Jupyter Notebook
2019 Community Moderator ElectionKeras - All layer names should be uniquewrap a general python function in tensorflowError when checking model target: expected dense_2 to have shape (None, 29430) but got array with shape (1108, 1)Getting the output of layer as a feature vector (KERAS)Keras Sequential model input layerWhat is the role of TimeDistributed layer in Keras?How does Keras read input data?Keras Model - Functional API - adding layers to existing modelKerras the definition of a model changes when the input tensor of the model is the output of another modelUse Glove vectors without Embedding layers in LSTMKeras functional api gives error “expected ndim=3, found ndim=4”
from keras import layers as KL
def create_model():
inp = KL.Input(shape=(None,), name='input')
embedding = KL.Embedding(input_dim=10, output_dim=10)(inp)
out = KL.Dense(1, activation='sigmoid', name='dense')(embedding)
model = KM.Model(inputs=[inp], outputs=[out])
return model
model1 = create_model()
model1.summary()
model2 = create_model()
model2.summary()
The output for model1:
embedding_1 (Embedding)
model2:
embedding_2 (Embedding)
Why the name of the layer is not fixed? If I run create_model()
again, the name will be suffixed with _3
.
Any idea? Does this has anything to do with running in Jupyter? Does Jupyter kernel somehow cache the variables? Thanks!
keras jupyter
add a comment |
from keras import layers as KL
def create_model():
inp = KL.Input(shape=(None,), name='input')
embedding = KL.Embedding(input_dim=10, output_dim=10)(inp)
out = KL.Dense(1, activation='sigmoid', name='dense')(embedding)
model = KM.Model(inputs=[inp], outputs=[out])
return model
model1 = create_model()
model1.summary()
model2 = create_model()
model2.summary()
The output for model1:
embedding_1 (Embedding)
model2:
embedding_2 (Embedding)
Why the name of the layer is not fixed? If I run create_model()
again, the name will be suffixed with _3
.
Any idea? Does this has anything to do with running in Jupyter? Does Jupyter kernel somehow cache the variables? Thanks!
keras jupyter
1
Keras does this, because layer names have to be unique.
– Matias Valdenegro
Mar 7 at 15:45
Does Keras maintain the layer names globally?create_model()
defines a new model every time it is called.
– zsong
Mar 7 at 15:47
It creates them so they are globally unique but they don't have to. Note that this has nothing to do with variable names.
– Matias Valdenegro
Mar 7 at 15:49
Is there a way to reset the counter? I need the layer names to be fixed because I need to port the model as tensforflow format and use it in C#. If the name of the layer is changed every time when the model is trained, I have to update the code.
– zsong
Mar 7 at 15:52
Possibly of help: Keras - All layer names should be unique
– desertnaut
Mar 7 at 15:56
add a comment |
from keras import layers as KL
def create_model():
inp = KL.Input(shape=(None,), name='input')
embedding = KL.Embedding(input_dim=10, output_dim=10)(inp)
out = KL.Dense(1, activation='sigmoid', name='dense')(embedding)
model = KM.Model(inputs=[inp], outputs=[out])
return model
model1 = create_model()
model1.summary()
model2 = create_model()
model2.summary()
The output for model1:
embedding_1 (Embedding)
model2:
embedding_2 (Embedding)
Why the name of the layer is not fixed? If I run create_model()
again, the name will be suffixed with _3
.
Any idea? Does this has anything to do with running in Jupyter? Does Jupyter kernel somehow cache the variables? Thanks!
keras jupyter
from keras import layers as KL
def create_model():
inp = KL.Input(shape=(None,), name='input')
embedding = KL.Embedding(input_dim=10, output_dim=10)(inp)
out = KL.Dense(1, activation='sigmoid', name='dense')(embedding)
model = KM.Model(inputs=[inp], outputs=[out])
return model
model1 = create_model()
model1.summary()
model2 = create_model()
model2.summary()
The output for model1:
embedding_1 (Embedding)
model2:
embedding_2 (Embedding)
Why the name of the layer is not fixed? If I run create_model()
again, the name will be suffixed with _3
.
Any idea? Does this has anything to do with running in Jupyter? Does Jupyter kernel somehow cache the variables? Thanks!
keras jupyter
keras jupyter
edited Mar 7 at 15:46
desertnaut
19.5k74076
19.5k74076
asked Mar 7 at 15:39
zsongzsong
45.2k22132194
45.2k22132194
1
Keras does this, because layer names have to be unique.
– Matias Valdenegro
Mar 7 at 15:45
Does Keras maintain the layer names globally?create_model()
defines a new model every time it is called.
– zsong
Mar 7 at 15:47
It creates them so they are globally unique but they don't have to. Note that this has nothing to do with variable names.
– Matias Valdenegro
Mar 7 at 15:49
Is there a way to reset the counter? I need the layer names to be fixed because I need to port the model as tensforflow format and use it in C#. If the name of the layer is changed every time when the model is trained, I have to update the code.
– zsong
Mar 7 at 15:52
Possibly of help: Keras - All layer names should be unique
– desertnaut
Mar 7 at 15:56
add a comment |
1
Keras does this, because layer names have to be unique.
– Matias Valdenegro
Mar 7 at 15:45
Does Keras maintain the layer names globally?create_model()
defines a new model every time it is called.
– zsong
Mar 7 at 15:47
It creates them so they are globally unique but they don't have to. Note that this has nothing to do with variable names.
– Matias Valdenegro
Mar 7 at 15:49
Is there a way to reset the counter? I need the layer names to be fixed because I need to port the model as tensforflow format and use it in C#. If the name of the layer is changed every time when the model is trained, I have to update the code.
– zsong
Mar 7 at 15:52
Possibly of help: Keras - All layer names should be unique
– desertnaut
Mar 7 at 15:56
1
1
Keras does this, because layer names have to be unique.
– Matias Valdenegro
Mar 7 at 15:45
Keras does this, because layer names have to be unique.
– Matias Valdenegro
Mar 7 at 15:45
Does Keras maintain the layer names globally?
create_model()
defines a new model every time it is called.– zsong
Mar 7 at 15:47
Does Keras maintain the layer names globally?
create_model()
defines a new model every time it is called.– zsong
Mar 7 at 15:47
It creates them so they are globally unique but they don't have to. Note that this has nothing to do with variable names.
– Matias Valdenegro
Mar 7 at 15:49
It creates them so they are globally unique but they don't have to. Note that this has nothing to do with variable names.
– Matias Valdenegro
Mar 7 at 15:49
Is there a way to reset the counter? I need the layer names to be fixed because I need to port the model as tensforflow format and use it in C#. If the name of the layer is changed every time when the model is trained, I have to update the code.
– zsong
Mar 7 at 15:52
Is there a way to reset the counter? I need the layer names to be fixed because I need to port the model as tensforflow format and use it in C#. If the name of the layer is changed every time when the model is trained, I have to update the code.
– zsong
Mar 7 at 15:52
Possibly of help: Keras - All layer names should be unique
– desertnaut
Mar 7 at 15:56
Possibly of help: Keras - All layer names should be unique
– desertnaut
Mar 7 at 15:56
add a comment |
1 Answer
1
active
oldest
votes
Each layer has a parameter called name
, which sets the layer name. You can use this to put your own fixed names to layers, so you can operate on them later.
For example:
conv1 = Conv2D(..., name='conv1')(some_input)
This won't work. The name will beembedding_1/embedding
orembedding_2/embedding
after ported as Tensorflow format
– zsong
Mar 7 at 15:59
1
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
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%2f55047605%2fweird-layer-suffix-issue-running-in-jupyter-notebook%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
Each layer has a parameter called name
, which sets the layer name. You can use this to put your own fixed names to layers, so you can operate on them later.
For example:
conv1 = Conv2D(..., name='conv1')(some_input)
This won't work. The name will beembedding_1/embedding
orembedding_2/embedding
after ported as Tensorflow format
– zsong
Mar 7 at 15:59
1
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
add a comment |
Each layer has a parameter called name
, which sets the layer name. You can use this to put your own fixed names to layers, so you can operate on them later.
For example:
conv1 = Conv2D(..., name='conv1')(some_input)
This won't work. The name will beembedding_1/embedding
orembedding_2/embedding
after ported as Tensorflow format
– zsong
Mar 7 at 15:59
1
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
add a comment |
Each layer has a parameter called name
, which sets the layer name. You can use this to put your own fixed names to layers, so you can operate on them later.
For example:
conv1 = Conv2D(..., name='conv1')(some_input)
Each layer has a parameter called name
, which sets the layer name. You can use this to put your own fixed names to layers, so you can operate on them later.
For example:
conv1 = Conv2D(..., name='conv1')(some_input)
answered Mar 7 at 15:54
Matias ValdenegroMatias Valdenegro
32k45581
32k45581
This won't work. The name will beembedding_1/embedding
orembedding_2/embedding
after ported as Tensorflow format
– zsong
Mar 7 at 15:59
1
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
add a comment |
This won't work. The name will beembedding_1/embedding
orembedding_2/embedding
after ported as Tensorflow format
– zsong
Mar 7 at 15:59
1
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
This won't work. The name will be
embedding_1/embedding
or embedding_2/embedding
after ported as Tensorflow format– zsong
Mar 7 at 15:59
This won't work. The name will be
embedding_1/embedding
or embedding_2/embedding
after ported as Tensorflow format– zsong
Mar 7 at 15:59
1
1
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
@zsong I get the feeling that we have a XY problem here, because you don't explain what exactly is the problem, but you are trying to make your solution work. Please state the full problem.
– Matias Valdenegro
Mar 7 at 16:04
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%2f55047605%2fweird-layer-suffix-issue-running-in-jupyter-notebook%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
1
Keras does this, because layer names have to be unique.
– Matias Valdenegro
Mar 7 at 15:45
Does Keras maintain the layer names globally?
create_model()
defines a new model every time it is called.– zsong
Mar 7 at 15:47
It creates them so they are globally unique but they don't have to. Note that this has nothing to do with variable names.
– Matias Valdenegro
Mar 7 at 15:49
Is there a way to reset the counter? I need the layer names to be fixed because I need to port the model as tensforflow format and use it in C#. If the name of the layer is changed every time when the model is trained, I have to update the code.
– zsong
Mar 7 at 15:52
Possibly of help: Keras - All layer names should be unique
– desertnaut
Mar 7 at 15:56