0

I know there is an issue with the line:

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])

I get the error:

AttributeError: 'BatchDataset' object has no attribute 'ndim'

and am using tensorflow's demo : image segmentation. I think it's to do with the input dimensions but can't find a way out of the problem.

Information for database:

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. it works in Google colab but just not on anaconda/spyder)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Helena Williams
  • 73
  • 2
  • 10
  • running on python 3.6 , anaconda, and spyder – Helena Williams Oct 12 '18 at 13:30
  • can you share the details related to your train_ds and val_ds? Difficult to pin point where the problem is otherwise – kvish Oct 12 '18 at 13:38
  • @kvish i just edited the question with the details – Helena Williams Oct 12 '18 at 13:45
  • I just took a look at the image segmentation notebook. Does the code corresponding to this block run on your system: temp_ds = get_baseline_dataset(x_train_filenames, y_train_filenames, preproc_fn=tr_preprocessing_fn, batch_size=1, shuffle=False) – kvish Oct 12 '18 at 14:19
  • 1
    Check [this](https://stackoverflow.com/a/54945768/14290244) comment helps to solve your problem. Thanks! –  Apr 16 '21 at 04:49

0 Answers0