Merge Keras Embeddings with normal models into one sequential ModelMerge 2 sequential models in Kerasloss, val_loss, acc and val_acc do not update at all over epochsUserWarning: Update your `Dense` call to the Keras 2 API:Implement perceptual loss with pretrained VGG using kerasHow does Keras read input data?Building an LSTM net with an embedding layer in KerasGet increasing loss and poor performance on Variational AutoencoderHow to save and reuse all settings for a keras model?scipy.ndimage.zoom is taking long time even on small arraysEpoch's steps taking too long on GPU'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model

Am I allowed to use personal conversation as a source?

Why force the nose of 737 Max down in the first place?

How can I say in Russian "they cannot make the tournament attractive by itself"?

How can I rectify up to 85 kV

How many oliphaunts died in all of the Lord of the Rings battles?

What is the most efficient way to write 'for' loops in Matlab?

Isolated audio without a transformer

What is the difference between 1/3, 1/2, and full casters?

Pointwise convergence of uniformly continuous functions to zero, but not uniformly

Why is the number of local variables used in a Java bytecode method not the most economical?

Please explain joy and/or the Kimatthiyasutta

Melee or Ranged attacks by Monsters, no distinction in modifiers?

If Trump gets impeached, how long would Pence be president?

What is this spacecraft tethered to another spacecraft in LEO (vintage)

Is there an antonym for "spicy" or "hot" regarding food (NOT "seasoned" but "spicy")?

Did the IBM PC use the 8088's NMI line?

What is the use of で in this sentence?

Why can't my huge trees be chopped down?

Unethical behavior : should I report it?

Converting 8V AC to 8V DC - bridge rectifier gets very hot while idling

Character is called by their first initial. How do I write it?

If my pay period is split between 2 calendar years, which tax year do I file them in?

How do I stop my characters falling in love?

How to tar a list of directories only if they exist



Merge Keras Embeddings with normal models into one sequential Model


Merge 2 sequential models in Kerasloss, val_loss, acc and val_acc do not update at all over epochsUserWarning: Update your `Dense` call to the Keras 2 API:Implement perceptual loss with pretrained VGG using kerasHow does Keras read input data?Building an LSTM net with an embedding layer in KerasGet increasing loss and poor performance on Variational AutoencoderHow to save and reuse all settings for a keras model?scipy.ndimage.zoom is taking long time even on small arraysEpoch's steps taking too long on GPU'Sequential' object has no attribute 'loss' - When I used GridSearchCV to tuning my Keras model






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to merge keras embeddings with normal models into one sequential model as in the notebook in this repository



from keras.layers import *
from keras.models import *

models = []

for categoical_var in categorical_vars :
model = Sequential()
model.reset_states( )
no_of_unique_cat = df[categoical_var].nunique()
embedding_size = min(np.ceil((no_of_unique_cat)/2), 50 )
embedding_size = int(embedding_size)
model.add( Embedding( no_of_unique_cat+1, embedding_size, input_length = 1 ) )
model.add(Reshape(target_shape=(embedding_size,)))
models.append( model )


model_rest = Sequential()
model_rest.add(Dense( 64 , input_dim = 6 ))
model_rest.reset_states( )
models.append(model_rest)

full_model = Sequential()
full_model.add(Merge(models, mode='concat'))

full_model.add(Dense(512))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(32))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(1))

full_model.compile(loss='mean_squared_error', optimizer='Adam',metrics=['mse','mape'])


The problem is new versions of keras doesn't use 'Merge' any more, I tried to use Concatenate, but it does not work with sequential models



Any help? I looked in to this, but it is a different problem










share|improve this question






















  • You should implement this using the Functional API, forget about the Sequential API.

    – Matias Valdenegro
    Mar 26 at 21:18











  • Keras still has Merge layers. Even if it does not, you can easily implement it through the Lambda layer

    – pitfall
    Mar 27 at 5:49











  • Can you please elaborate on this?

    –  owise
    Mar 27 at 14:38

















0















I want to merge keras embeddings with normal models into one sequential model as in the notebook in this repository



from keras.layers import *
from keras.models import *

models = []

for categoical_var in categorical_vars :
model = Sequential()
model.reset_states( )
no_of_unique_cat = df[categoical_var].nunique()
embedding_size = min(np.ceil((no_of_unique_cat)/2), 50 )
embedding_size = int(embedding_size)
model.add( Embedding( no_of_unique_cat+1, embedding_size, input_length = 1 ) )
model.add(Reshape(target_shape=(embedding_size,)))
models.append( model )


model_rest = Sequential()
model_rest.add(Dense( 64 , input_dim = 6 ))
model_rest.reset_states( )
models.append(model_rest)

full_model = Sequential()
full_model.add(Merge(models, mode='concat'))

full_model.add(Dense(512))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(32))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(1))

full_model.compile(loss='mean_squared_error', optimizer='Adam',metrics=['mse','mape'])


The problem is new versions of keras doesn't use 'Merge' any more, I tried to use Concatenate, but it does not work with sequential models



Any help? I looked in to this, but it is a different problem










share|improve this question






















  • You should implement this using the Functional API, forget about the Sequential API.

    – Matias Valdenegro
    Mar 26 at 21:18











  • Keras still has Merge layers. Even if it does not, you can easily implement it through the Lambda layer

    – pitfall
    Mar 27 at 5:49











  • Can you please elaborate on this?

    –  owise
    Mar 27 at 14:38













0












0








0








I want to merge keras embeddings with normal models into one sequential model as in the notebook in this repository



from keras.layers import *
from keras.models import *

models = []

for categoical_var in categorical_vars :
model = Sequential()
model.reset_states( )
no_of_unique_cat = df[categoical_var].nunique()
embedding_size = min(np.ceil((no_of_unique_cat)/2), 50 )
embedding_size = int(embedding_size)
model.add( Embedding( no_of_unique_cat+1, embedding_size, input_length = 1 ) )
model.add(Reshape(target_shape=(embedding_size,)))
models.append( model )


model_rest = Sequential()
model_rest.add(Dense( 64 , input_dim = 6 ))
model_rest.reset_states( )
models.append(model_rest)

full_model = Sequential()
full_model.add(Merge(models, mode='concat'))

full_model.add(Dense(512))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(32))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(1))

full_model.compile(loss='mean_squared_error', optimizer='Adam',metrics=['mse','mape'])


The problem is new versions of keras doesn't use 'Merge' any more, I tried to use Concatenate, but it does not work with sequential models



Any help? I looked in to this, but it is a different problem










share|improve this question














I want to merge keras embeddings with normal models into one sequential model as in the notebook in this repository



from keras.layers import *
from keras.models import *

models = []

for categoical_var in categorical_vars :
model = Sequential()
model.reset_states( )
no_of_unique_cat = df[categoical_var].nunique()
embedding_size = min(np.ceil((no_of_unique_cat)/2), 50 )
embedding_size = int(embedding_size)
model.add( Embedding( no_of_unique_cat+1, embedding_size, input_length = 1 ) )
model.add(Reshape(target_shape=(embedding_size,)))
models.append( model )


model_rest = Sequential()
model_rest.add(Dense( 64 , input_dim = 6 ))
model_rest.reset_states( )
models.append(model_rest)

full_model = Sequential()
full_model.add(Merge(models, mode='concat'))

full_model.add(Dense(512))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(32))
full_model.add(Activation('sigmoid'))
full_model.add(Dropout(0.2))

full_model.add(Dense(1))

full_model.compile(loss='mean_squared_error', optimizer='Adam',metrics=['mse','mape'])


The problem is new versions of keras doesn't use 'Merge' any more, I tried to use Concatenate, but it does not work with sequential models



Any help? I looked in to this, but it is a different problem







tensorflow keras neural-network deep-learning keras-layer






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 18:48









owise owise

4665 silver badges19 bronze badges




4665 silver badges19 bronze badges












  • You should implement this using the Functional API, forget about the Sequential API.

    – Matias Valdenegro
    Mar 26 at 21:18











  • Keras still has Merge layers. Even if it does not, you can easily implement it through the Lambda layer

    – pitfall
    Mar 27 at 5:49











  • Can you please elaborate on this?

    –  owise
    Mar 27 at 14:38

















  • You should implement this using the Functional API, forget about the Sequential API.

    – Matias Valdenegro
    Mar 26 at 21:18











  • Keras still has Merge layers. Even if it does not, you can easily implement it through the Lambda layer

    – pitfall
    Mar 27 at 5:49











  • Can you please elaborate on this?

    –  owise
    Mar 27 at 14:38
















You should implement this using the Functional API, forget about the Sequential API.

– Matias Valdenegro
Mar 26 at 21:18





You should implement this using the Functional API, forget about the Sequential API.

– Matias Valdenegro
Mar 26 at 21:18













Keras still has Merge layers. Even if it does not, you can easily implement it through the Lambda layer

– pitfall
Mar 27 at 5:49





Keras still has Merge layers. Even if it does not, you can easily implement it through the Lambda layer

– pitfall
Mar 27 at 5:49













Can you please elaborate on this?

–  owise
Mar 27 at 14:38





Can you please elaborate on this?

–  owise
Mar 27 at 14:38












0






active

oldest

votes










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364306%2fmerge-keras-embeddings-with-normal-models-into-one-sequential-model%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364306%2fmerge-keras-embeddings-with-normal-models-into-one-sequential-model%23new-answer', 'question_page');

);

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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript