1、keras多输入二分类与多分类
二分类
X11=X1.reshape(X1.shape[0],n_timesteps,X1.shape[1])
X22=X2.reshape(X2.shape[0],n_timesteps,X2.shape[1])
X33=X3.reshape(X3.shape[0],n_timesteps,X3.shape[1])
# y1=OneHotEncoder(sparse = False).fit_transform(y)
# y2 = y1.reshape(y1.shape[0],1,y1.shape[1])
y1 = np.reshape(np.array(clicks_all1_100000_new['gender']),(-1,1))
y2=OneHotEncoder(sparse = False).fit_transform(y1)
y3 = y2.reshape(y2.shape[0],1,y2.shape[1])
print(X11,y3)
# define two sets of inputs
inputA = Input(shape=(1,30))
inputB = Input(shape=(1,30))
inputC = Input(shape=(1,30))
# the first branch operates on the first input
x = Bidirectional(LSTM(60, return_sequences=True))(inputA)
# x = Dense(8, activation="relu")(inputA)
x = Dense(10, activation="relu")(x)
# x = Model(inputs=inputA, outputs=x)
# the second branch opreates on the second input
y = Bidirectional(LSTM(60, return_sequences=True))(inputB)
# y = Dense(32, activation="relu")(y)
y = Dense(10, activation="relu")(y)
# y = Model(inputs=inputB, outputs=y)
z = Bidirectional(LSTM(60, return_sequences=True))(inputC)
# x = Dense(8, activation="relu")(inputA)
z = Dense(10, activation="relu")(z)
# z = Model(inputs=inputC, outputs=z)
# combine the output of the two branches
combined = concatenate([x,