Zahlii/colab-tf-utils

IndexError: list index out of range

GeorgeMurAlkh opened this issue · 2 comments


IndexError                                Traceback (most recent call last)
<ipython-input-22-543c5fbe3f75> in <module>()
    166     epochs=EPOCHS,
    167     validation_data=(validation_x, validation_y),
--> 168     callbacks=[utils.GDriveCheckpointer(compare,path)],
    169 )
    170 

/content/utils.py in __init__(self, compare_fn, filepath_fn, save_optimizer)
    161         super(GDriveCheckpointer, self).__init__()
    162 
--> 163         self.saver = GDriveSync()
    164 
    165         self.compare_fn = compare_fn

/content/utils.py in __init__(self)
     46 
     47         self.drive_service = build('drive', 'v3')
---> 48         self.default_folder = self.find_items('Colab Notebooks')[0]
     49 
     50     def find_items(self, name):

IndexError: list index out of range

Code:

def compare(best, new):
  return best.losses['val_acc'] < new.losses['val_acc']

def path(new):
  if new.losses['val_acc'] > 0.5:
    return 'RNN_Final_{0}.model'.format(new.losses['val_acc'])

# Train model callbacks=[tensorboard, checkpoint],
history = model.fit(
    train_x, train_y,
    batch_size=BATCH_SIZE,
    epochs=EPOCHS,
    validation_data=(validation_x, validation_y),
    callbacks=[utils.GDriveCheckpointer(compare,path)]
)

Have no Idea why I'm getting this error.
Previously in code loaded GD service to load files, maybe this is hot spot:

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

f1 = drive.CreateFile({'id': 'id'})
f1.GetContentFile('file.csv')

Would be grateful for any help.

Hi, please make sure that the folder "Colab Notebooks" exists on the GDrive account you are signing in with. The error means the folder can not be found :)

Thats work! Thank you!