首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用talos的网格搜索:传递输入错误列表

使用talos的网格搜索:传递输入错误列表
EN

Stack Overflow用户
提问于 2019-03-12 06:00:30
回答 1查看 104关注 0票数 0

我使用的是keras函数API。

我正在尝试传递一个输入列表。

我尝试遵循这个issue

但我仍然收到一个错误:

代码语言:javascript
复制
AttributeError: 'list' object has no attribute 'max'

这是我目前的模型:

代码语言:javascript
复制
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())

我的网格搜索参数是:

代码语言:javascript
复制
parameters = {'batch_size': [10,20]}

当我运行以下命令时,我得到了错误:

代码语言:javascript
复制
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图像)

EN

回答 1

Stack Overflow用户

发布于 2019-07-13 04:39:38

我猜你解决了这个问题?如果不是,那是因为talos希望xy是numpy数组。如果它们是numpy数组,这意味着talos可以对它们调用max(),而您不能对列表调用max(),这是您提供给.Scan()的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55111053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档