kar*_*tel 7 python machine-learning neural-network deep-learning keras
Aux_input = Input(shape=(wrd_temp.shape[1],1), dtype='float32')#shape (,200)
Main_input = Input(shape=(wrdvec.shape[1],),dtype='float32')#shape(,367)
X = Bidirectional(LSTM(20,return_sequences=True))(Aux_input)
X = Dropout(0.2)(X)
X = Bidirectional(LSTM(28,return_sequences=True))(X)
X = Dropout(0.2)(X)
X = Bidirectional(LSTM(28,return_sequences=False))(X)
Aux_Output = Dense(Opt_train.shape[1], activation= 'softmax' )(X)#total 22 classes
x = keras.layers.concatenate([Main_input,Aux_Output],axis=1)
x = tf.reshape(x,[1,389,1])#here 389 is the shape of the new input i.e.(
Main_input+Aux_Output)
x = Bidirectional(LSTM(20,return_sequences=True))(x)
x = Dropout(0.2)(x)
x = Bidirectional(LSTM(28,return_sequences=True))(x)
x = Dropout(0.2)(x)
x = Bidirectional(LSTM(28,return_sequences=False))(x)
Main_Output = Dense(Opt_train.shape[1], activation= 'softmax' )(x)
model = Model(inputs=[Aux_input,Main_input], outputs= [Aux_Output,Main_Output])
Run Code Online (Sandbox Code Playgroud)
在声明模型的行中出现错误,即模型= Model(),这里发生了属性错误.如果我的实现中有任何其他错误,请在评论部分中取消并通知我.
问题在于使用tf以下任何一种方法封装了每个操作:
keras.backend功能Lambda 层keras功能具有相同的行为。当您使用tf操作时-您将获得tf没有history字段的张量对象。使用keras函数时,将得到keras.tensor。
| 归档时间: |
|
| 查看次数: |
4880 次 |
| 最近记录: |