google colaboratory, weight download (export saved models)

后端 未结 7 1908
执念已碎
执念已碎 2021-01-30 14:36

I created a model using Keras library and saved the model as .json and its weights with .h5 extension. How can I download this onto my local machine?

to save the model I

7条回答
  •  你的背包
    2021-01-30 15:17

    files.download does not let you directly download large files. A workaround is to save your weights on Google drive, using this pydrive snippet below. Just change the filename.txt for your weights.h5 file

    # Install the PyDrive wrapper & import libraries.
    # This only needs to be done once in a notebook.
    !pip install -U -q PyDrive
    from pydrive.auth import GoogleAuth
    from pydrive.drive import GoogleDrive
    from google.colab import auth
    from oauth2client.client import GoogleCredentials
    
    # Authenticate and create the PyDrive client.
    # This only needs to be done once in a notebook.
    auth.authenticate_user()
    gauth = GoogleAuth()
    gauth.credentials = GoogleCredentials.get_application_default()
    drive = GoogleDrive(gauth)
    
    # Create & upload a file.
    uploaded = drive.CreateFile({'title': 'filename.csv'})
    uploaded.SetContentFile('filename.csv')
    uploaded.Upload()
    print('Uploaded file with ID {}'.format(uploaded.get('id')))
    

提交回复
热议问题