在Keras中使用scikit-learn进行单输入多输出模型

时间:2017-08-22 05:40:13

标签: tensorflow scikit-learn keras

我正在尝试使用Keras中的scikit-learn来微调具有一个输入(图像)和2个输出(旋转矢量和平移矢量)的模型。代码段如下,

img_input =Input(shape=(img_rows, img_cols, img_channels))
model = KerasRegressor(build_fn = toy_model, verbose = 1)
loss_weights = [[1.0, 250.0], [1.0, 500.0], [1.0, 750.0]]
epochs =[10, 20]
batches = [5, 10]
param_grid = dict(loss_weight= loss_weights, epochs = epochs, 
batch_size = batches)
grid = GridSearchCV(estimator = model, param_grid=param_grid)
grid_result = grid.fit(train_imgs, [train_pose_tx, train_pose_rt])

我想微调" loss_weights"此模型的参数。但是,我收到以下错误

ValueError: Found input variables with inconsistent numbers of samples:[895, 2] 

据我所知,由于此模型具有单个输入,因此必须支持此功能。 链接到Github要点: https://gist.github.com/sushant4788/1f84cd2781f96fb752ee1f16a56d1bcb

0 个答案:

没有答案