我正在使用 keras 功能 API。
我正在尝试传入输入列表。
我试图关注这个问题:
但我仍然收到一个错误:
AttributeError: 'list' object has no attribute 'max'
这是我目前的模型:
def create_model(x_train,y_train, parameters):
# Multiple Inputs
# 1st input model
frame1 = Input(shape=(9216,))
hidden1 = Dense(30, activation='relu')(frame1)
hidden1= Dropout(0.2)(hidden1)
hidden1 = Dense(50, activation='relu')(hidden1)
#hidden1 = Dense(30, activation='relu')(hidden1)
output1 = Dense(10, activation='softmax')(hidden1)
# 2nd input model
frame2 = Input(shape=(9216,))
hidden2 = Dense(30, activation='relu')(frame2)
hidden1= Dropout(0.2)(hidden2)
hidden2 = Dense(50, activation='relu')(hidden2)
#hidden2 = Dense(30, activation='relu')(hidden2)
output2 = Dense(10, activation='softmax')(hidden2)
model = Model(inputs=[x1, x2],
outputs=[output1, output2])
#Compile the model
model.compile(optimizer='adam', loss='mse', metrics=['mse'])
history = model.fit(model.fit(x=x_train,y=y_train,
validation_split=0.2,
batch_size=parameters['batch_size'],
shuffle=False,
epochs=20,
verbose=1))
return history, model
# summarize layers
print(model.summary())
我的网格搜索参数是:
parameters = {'batch_size': [10,20]}
运行此程序时出现错误:
import talos as ta
t = ta.Scan([train1,train2],
[y1,y2],
params=p,
model=model)
AttributeError: 'list' object has no attribute 'max'
请注意,我的 train1、train2 是具有 9216 个值的 numpy 数组。(96x96 图像)