1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| import tensorflow.keras as keras from zipfile import ZipFile from pathlib import Path
import os
zipped_url = ( 'http://files.grouplens.org/datasets/movielens/ml-latest-small.zip' )
zipped_file = keras.utils.get_file( 'zipped_dataset.zip', zipped_url, extract=True )
keras_path = Path(zipped_file).parents[0] print('datasets path:', keras_path)
print(os.listdir(keras_path))
movielens_dir = keras_path / os.listdir(keras_path)[0]
if not movielens_dir.exists(): with ZipFile(zipped_file, "r") as zip: zip.extractall(path=keras_path) print(os.listdir(movielens_dir))
|