Skip to content

Instantly share code, notes, and snippets.

@tocom242242
Created July 17, 2019 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tocom242242/a43363e2ef11bfc3c243372787819ce2 to your computer and use it in GitHub Desktop.
Save tocom242242/a43363e2ef11bfc3c243372787819ce2 to your computer and use it in GitHub Desktop.
keras,divide middle layer
import keras
from keras.layers import Input, Dense, Lambda, concatenate
from keras.models import Model
from keras.utils import plot_model
inputs = Input(shape=(10,))
x1_1 = Lambda(lambda x:x[:,:5],output_shape=(5,))(inputs)
x1_2 = Lambda(lambda x:x[:,5:],output_shape=(5,))(inputs)
x2 = concatenate([x1_1, x1_2])
x3 = Dense(10)(x2)
model = Model(inputs=inputs,outputs=x3)
plot_model(model,"model.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment