This commit is contained in:
REDMOND\sayanpa 2017-03-27 19:13:32 -07:00
Родитель 156028a4dc
Коммит 97782a2098
4 изменённых файлов: 93 добавлений и 264 удалений

Просмотреть файл

@ -10,6 +10,29 @@ from shutil import copyfile
envvar = 'CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'
# Generic helper to read data from 'CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY' to local machine
# One should use this helper when copying code is needed
# TODO: Update the other data loaders to reuse this code
def _data_copier(src_files, dst_files):
src_files = [os.path.normpath(os.path.join((os.environ[envvar]), \
*src_file.split("/"))) for src_file in src_files]
dst_files = [os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(os.getcwd())), \
*dst_file.split("/"))) for dst_file in dst_files]
if not len(src_files) == len(dst_files):
raise Exception('The length of src and dst should be same')
for src_dst_file in zip(src_files, dst_files):
# Note index 0 is the source and index 1 is destination
if not os.path.isfile(src_dst_file[1]):
# copy from backup location
print("Copying file from: ", src_dst_file[0])
print("Copying file to: ", src_dst_file[1])
copyfile( src_dst_file[0], src_dst_file[1])
else:
print("Reusing cached file", src_dst_file[1])
def prepare_CIFAR10_data():
base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
*"../../../../Examples/Image/DataSets/CIFAR-10".split("/"))
@ -18,7 +41,7 @@ def prepare_CIFAR10_data():
# If {train,test}_map.txt don't exist locally, copy to local location
if not (os.path.isfile(os.path.join(base_path, 'train_map.txt')) and os.path.isfile(os.path.join(base_path, 'test_map.txt'))):
# copy from backup location
base_path_bak = os.path.join(os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'],
base_path_bak = os.path.join(os.environ[envvar],
*"Image/CIFAR/v0/cifar-10-batches-py".split("/"))
base_path_bak = os.path.normpath(base_path_bak)
@ -40,7 +63,7 @@ def prepare_ImageNet_data():
# If val1024_map.txt don't exist locally, copy to local location
if not (os.path.isfile(os.path.join(base_path, 'train_map.txt')) and os.path.isfile(os.path.join(base_path, 'val_map.txt'))):
# copy from backup location
base_path_bak = os.path.join(os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'],
base_path_bak = os.path.join(os.environ[envvar],
*"Image/ImageNet/2012/v0".split("/"))
base_path_bak = os.path.normpath(base_path_bak)
@ -57,7 +80,7 @@ def prepare_Grocery_data():
# If val1024_map.txt don't exist locally, copy to local location
if not os.path.isfile(os.path.join(base_path, 'test.txt')):
# copy from backup location
base_path_bak = os.path.join(os.environ['CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY'],
base_path_bak = os.path.join(os.environ[envvar],
*"Image/Grocery".split("/"))
base_path_bak = os.path.normpath(base_path_bak)
@ -81,26 +104,6 @@ def cmudict_dataset_directory():
base_path = os.path.normpath(base_path)
return base_path
# Generic helper to read data from 'CNTK_EXTERNAL_TESTDATA_SOURCE_DIRECTORY' to local machine
def _data_copier(src_files, dst_files):
src_files = [os.path.normpath(os.path.join((os.environ[envvar]), \
*src_file.split("/"))) for src_file in src_files]
dst_files = [os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(os.getcwd())), \
*dst_file.split("/"))) for dst_file in dst_files]
if not len(src_files) == len(dst_files):
raise Exception('The length of src and dst should be same')
for idx, dst in enumerate(dst_files):
if not os.path.isfile(dst):
# copy from backup location
print("Copying file from: ", src_files[idx])
print("Copying file to: ", dst)
copyfile( src_files[idx], dst)
else:
print("Reusing cached file", dst)
# Read the flower and animal data set file
def prepare_resnet_v1_model():
@ -126,32 +129,3 @@ def prepare_animals_data():
dst_file = "Examples/Image/DataSets/Animals/Animals.zip"
_data_copier([src_file], [dst_file])
def prepare_ResNetmodel_and_Flower_Animals_data():
src_files = ["PreTrainedModels/ResNet/v1/ResNet_18.model",
"Image/Flowers/102flowers.tgz",
"Image/Flowers/imagelabels.mat",
"Image/Flowers/imagelabels.mat",
"Image/Animals/Animals.zip"]
src_files = [os.path.normpath(os.path.join((os.environ[envvar]), \
*src_file.split("/"))) for src_file in src_files]
dst_files = ["Examples/Image/PretrainedModels/ResNet_18.model",
"Examples/Image/DataSets/Flowers/102flowers.tgz",
"Examples/Image/DataSets/Flowers/imagelabels.mat",
"Examples/Image/DataSets/Flowers/imagelabels.mat",
"Examples/Image/DataSets/Animals/Animals.zip"]
dst_files = [os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(os.getcwd())), \
*dst_file.split("/"))) for dst_file in dst_files]
for idx, dst in enumerate(dst_files):
if not os.path.isfile(dst):
# copy from backup location
print("Copying file from: ", src_files[idx])
print("Copying file to: ", dst)
copyfile( src_files[idx], dst)
else:
print("Reusing cached file", dst)

Просмотреть файл

@ -35,7 +35,7 @@
"category": ["Image"],
"name": "Transfer Learning",
"url": "https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_301_Image_Recognition_with_Deep_Transfer_Learning.ipynb",
"description": "Recognize flowers and animal in natural scene images using deep transfer learning with pre-trained ResNet data.",
"description": "Recognize flowers and animals in natural scene images using deep transfer learning with pre-trained ResNet data.",
"language": ["Python"],
"type": ["Tutorial", "Recipe"]
},

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -45,7 +45,7 @@ Tutorials
Try these notebooks pre-installed on `CNTK Azure Notebooks`_ for free.
For our Japanese users, you can find some of the `tutorials in Japanese`_.
For our Japanese users, you can find some of the `tutorials in Japanese`_ (unsupported).
.. _`Logistic Regression`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_101_LogisticRegression.ipynb
.. _`Feed Forward network`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_102_FeedForward.ipynb
@ -61,8 +61,9 @@ For our Japanese users, you can find some of the `tutorials in Japanese`_.
.. _`Sequence to sequence basics`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_204_Sequence_To_Sequence.ipynb
.. _`Artistic Style Transfer`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_205_Artistic_Style_Transfer.ipynb
.. _`Basic Generative Adversarial Networks (GAN)`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_206_Basic_GAN.ipynb
.. _`Deep Convolutional GAN`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_206B_DCGAN.ipynb
.. _`Training with Sampled Softmax`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_207_Training_with_Sampled_Softmax.ipynb
.. _`Deep transfer learning with pre-trained ResNet model`: https://github.com/Microsoft/CNTK/blob/v2.0.beta12.0/Tutorials/CNTK_301_Image_Recognition_with_Deep_Transfer_Learning.ipynb
.. _`Deep transfer learning with pre-trained ResNet model`: https://github.com/Microsoft/CNTK/blob/v2.0.beta15.0/Tutorials/CNTK_301_Image_Recognition_with_Deep_Transfer_Learning.ipynb
.. _`CNTK Azure Notebooks`: https://notebooks.azure.com/cntk/libraries/tutorials
.. _`tutorials in Japanese`: https://notebooks.azure.com/library/cntkbeta2_ja