首页 > 解决方案 > KERAS: AttributeError: 'BatchDataset' object has no attribute 'ndim' ,Tensorflow 图像分割演示不适用于我的 anaconda

问题描述

我知道这条线有问题:

history = model.fit(train_ds,
                   steps_per_epoch=int(np.ceil(num_train_examples / float(batch_size))),
                   epochs=epochs,
                   validation_data=val_ds,
                   validation_steps=int(np.ceil(num_val_examples / float(batch_size))),
                   callbacks=[cp])

我得到错误:

AttributeError:“BatchDataset”对象没有属性“ndim”

并且正在使用 tensorflow 的演示:图像分割。我认为这与输入尺寸有关,但找不到解决问题的方法。

数据库信息:

train_ds = get_baseline_dataset(x_train_filenames,
                                y_train_filenames,
                                preproc_fn=tr_preprocessing_fn,
                                batch_size=batch_size)
val_ds = get_baseline_dataset(x_val_filenames,
                              y_val_filenames, 
                              preproc_fn=val_preprocessing_fn,
                              batch_size=batch_size)
   

def get_baseline_dataset(filenames, 
                         labels,
                         preproc_fn=functools.partial(_augment),
                         threads=5, 
                         batch_size=batch_size,
                         shuffle=True):    

(ps。它在 Google colab 中有效,但在 anaconda/spyder 上无效)

标签: pythonimagetensorflowkaggle

解决方案


推荐阅读