首页 > 解决方案 > 为什么 colab 会抛出此错误,但不会在 kaggle 中抛出此错误,ValueError: Failed to find data adapter that can handle input

问题描述

错误: ValueError: Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'>

我正在尝试做的事情- 嗯,我正在尝试建立一个模型来检测导管位置。起初,我在 kaggle 中编写了相同的代码,然后代码很好,没有任何错误,但相同的代码在 colab 中给出了错误。

代码:请在此处找到完整的Colab Notebook

这是 model.fit 代码

history = model.fit(dtrain,epochs=2,
                    verbose=1,
                    callbacks=[checkpoint, lr_reducer, early_stop], 
                    steps_per_epoch=steps_per_epoch,
                    validation_data=dvalid)

Colab 在validation_data =dvalid这一行显示错误。dvalid 代码如下。

size = 384
BATCH_SIZE=32

decoder = build_decoder(with_labels=True, target_size=(size, size))
test_decoder = build_decoder(with_labels=False, target_size=(size, size))

dtrain = build_dataset(train_paths, train_labels, bsize=BATCH_SIZE, 
    cache_dir='tf_cache', decode_fn=decoder)

dvalid = build_dataset(
    valid_paths, valid_labels, bsize=BATCH_SIZE, 
    repeat=False, shuffle=False, augment=False, 
    cache_dir='tf_cache', decode_fn=decoder)

dtest = build_dataset(
    test_paths, bsize=BATCH_SIZE, repeat=False, 
    shuffle=False, augment=False, cache=False, 
    decode_fn=test_decoder)

我试过的

我尝试将数据转换为 numpy 数组,但仍然抛出相同的错误。

train_paths = np.asarray(train_paths)
train_labels = np.asarray(train_labels)
valid_paths = np.asarray(valid_paths)
valid_labels = np.asarray(valid_labels)

请查看代码并帮助我解决此错误。提前致谢

标签: pythonmachine-learninggoogle-colaboratorykaggleimage-classification

解决方案


推荐阅读