我试图制作一个具有多个输入和输出的训练模型。
这个模型在单个输入和输出上工作得很好,但我收到了一条错误消息。
AttributeError:“numpy.ndarray”对象没有属性“strip”
我想问题是 fit_generator 无法处理 numpy 数组。
我的 fit 生成器如下所示:
def train_model(model, X_train, X_valid, y_train, y_valid):
"""
Train the model
"""
checkpoint = ModelCheckpoint('model-{epoch:03d}-Hunet-LSTM-Canny_Final_bc50.h5',
monitor='val_loss',
verbose=0,
save_best_only=True,
mode='auto')
model.compile(loss='mse', optimizer=Adam(lr=0.0001))
X=X_train
print(X)
y=y_train
print(y)
history = model.fit_generator(batcher(data_dir, X_train, y_train, batch_size, True),
samples_per_epoch,
nb_epoch,
max_q_size=1,
validation_data=batcher(data_dir, X_valid, y_valid, batch_size, False),
nb_val_samples=len(X_valid),
callbacks=[checkpoint],
verbose=1)
以及 Print(X_train) 的结果
[['images/photo6190.jpg' 0.119999997318]
['images/photo8791.jpg' 0.10000000149]
['images/photo12711.jpg' 0.060000006109499994]
...
['images/photo9846.jpg' 0.0700000077486]
['images/photo10800.jpg' 0.109999999404]
['images/photo2733.jpg' 0.10000000149]]
并打印(y_train)
[[ 0.20000002 0.12 ]
[ 0.30000001 0.1 ]
[-0.19999999 0.06000001]
...
[ 0.30000001 0.07000001]
[ 0.5 0.11 ]
[ 0.40000001 0.1 ]]
有什么办法修复它吗?