Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Importing Kaggle dataset into google colaboratory

  • Difficulty Level : Basic
  • Last Updated : 16 Jul, 2020

While building a Deep Learning model, the first task is to import datasets online and this task proves to be very hectic sometimes.
We can easily import Kaggle datasets in just a few steps:
Code: Importing CIFAR 10 dataset

Attention reader! Don’t stop learning now. Get hold of all the important Machine Learning Concepts with the Machine Learning Foundation Course at a student-friendly price and become industry ready.






!pip install kaggle

Now go to your Kaggle account and create new API token from my account section, a kaggle.json file will be downloaded in your PC.
Code:






from google.colab import files
files.upload()

Code: Uploading the kaggle.json file




!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!chmod 600 ~/.kaggle/kaggle.json

Copy the URL of your dataset and paste it in another cell.

Code: To unzip the uploaded dataset.




from zipfile import Zipfile
file_name=("cifar10-preprocessed.zip")
with Zipfile(file_name,'r') as zip:
             zip.extractall()
             print("done")

Code:




'./get_CIFAR-10.sh'
import tensorflow as tf
  
(x_train,y_train),(x_test,y_test) = tf.keras.cifar10.load_data()

Now your training and test set is ready to be used.




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!