<jupyter_start><jupyter_text>初始化环境 1. 安装kaggle-cli2. 使用kaggle-cli下载猫狗数据集3. 解压猫狗数据集  安装Kaggle-cli<jupyter_code>!pip install kaggle<jupyter_output>Requirement already satisfied: kaggle in d:\programdata\anaconda2\envs\keras\lib\site-packages
Requirement already satisfied: six>=1.10 in d:\programdata\anaconda2\envs\keras\lib\site-packages (from kaggle)
Requirement already satisfied: tqdm in d:\programdata\anaconda2\envs\keras\lib\site-packages (from kaggle)
Requirement already satisfied: python-dateutil in d:\programdata\anaconda2\envs\keras\lib\site-packages (from kaggle)
Requirement already satisfied: urllib3>=1.15 in d:\programdata\anaconda2\envs\keras\lib\site-packages (from kaggle)
Requirement already satisfied: requests in d:\programdata\anaconda2\envs\keras\lib\site-packages (from kaggle)
Requirement already satisfied: certifi in d:\programdata\anaconda2\envs\keras\lib\site-packages (from kaggle)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in d:\programdata\anaconda2\envs\keras\lib\site-packages (from requests->kaggle)
Requirement already satisfied: idna<2.7,>=2.5 in d:\programdata\anaconda2\envs\keras\lib\site-pac[...]<jupyter_text>下载猫狗数据集<jupyter_code>!kaggle competitions download -c dogs-vs-cats-redux-kernels-edition -p data<jupyter_output><empty_output><jupyter_text>解压数据集<jupyter_code>import zipfile
import os
#     train_dataset_zip_path = './data/dogs-vs-cats-redux-kernels-edition/train.zip'
#     test_dataset_zip_path = './data/dogs-vs-cats-redux-kernels-edition/test.zip'

dataset_path = './data/'

train_dataset_zip_path = './data/train.zip'
test_dataset_zip_path = './data/test.zip'

def unzip(save_path, data_path, data_name):
    """
    Unzip wrapper with the same interface as _ungzip
    :param save_path: The path of the zip files
    :param data_path: Path to extract to
    :param data_name: Name of dataset
    """
    if not os.path.exists(save_path):
        print('File {} does not exist'.format(data_name))
        return

    print('Extracting data {} ...'.format(data_name))
    with zipfile.ZipFile(save_path) as zf:
        zf.extractall(data_path)
        print('Extract {} Finish!'.format(data_name))



if not os.path.exists(dataset_path + 'train'):
    unzip(train_dataset_zip_path, dataset_path, 'train.zip')
else:
    print('Found {} Data'.format('train.zip'))

if not os.path.exists(dataset_path + 'test'):
    unzip(test_dataset_zip_path, dataset_path, 'test.zip')
else:
    print('Found {} Data'.format('test.zip'))<jupyter_output>Found train.zip Data
Found test.zip Data
{'fraction_non_alphanumeric': 0.12819504522217853, 'fraction_numerical': 0.011403853716083366, 'mean_word_length': 4.95784543325527, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '532674', 'license': 'MIT', 'n_tokens_mistral': 948, 'n_tokens_neox': 948, 'n_words': 168, 'path': '0.Environment_setting.ipynb', 'repo_name': 'zqyadam/dog_vs_cat', 'size': '2543'}