make changes on notebook based on the structure change
This commit is contained in:
Родитель
cc0fabcd55
Коммит
0af38f7ccb
|
@ -121,12 +121,12 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"* Go through the [Configuration](https://github.com/Azure/MachineLearningNotebooks/blob/master/configuration.ipynb) notebook to install the Azure Machine Learning Python SDK and create an Azure ML `Workspace`"
|
||||
"Go through the [Configuration](https://github.com/Azure/MachineLearningNotebooks/blob/master/configuration.ipynb) notebook to install the Azure Machine Learning Python SDK and create an Azure ML `Workspace`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 117,
|
||||
"execution_count": 21,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
@ -136,7 +136,7 @@
|
|||
"output_type": "stream",
|
||||
"text": [
|
||||
"System version: 3.6.8 |Anaconda, Inc.| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]\n",
|
||||
"Azure ML SDK Version: 1.0.33\n",
|
||||
"Azure ML SDK Version: 1.0.43\n",
|
||||
"Pandas version: 0.24.2\n"
|
||||
]
|
||||
}
|
||||
|
@ -158,13 +158,14 @@
|
|||
"from utils_nlp.dataset.preprocess import to_lowercase, to_nltk_tokens\n",
|
||||
"from utils_nlp.dataset import snli\n",
|
||||
"from utils_nlp.azureml import azureml_utils\n",
|
||||
"from utils_nlp.model.gensen.gensen_utils import gensen_preprocess\n",
|
||||
"from utils_nlp.gensen.preprocess_utils import gensen_preprocess\n",
|
||||
"\n",
|
||||
"import azureml.data\n",
|
||||
"from azureml.data.azure_storage_datastore import AzureFileDatastore\n",
|
||||
"from azureml.core.compute import ComputeTarget, AmlCompute\n",
|
||||
"from azureml.core.compute_target import ComputeTargetException\n",
|
||||
"from azureml.core import Experiment, get_run\n",
|
||||
"from azureml.core.runconfig import MpiConfiguration\n",
|
||||
"from azureml.train.dnn import PyTorch\n",
|
||||
"from azureml.train.estimator import Estimator\n",
|
||||
"from azureml.train.hyperdrive import RandomParameterSampling, BanditPolicy, HyperDriveRunConfig, uniform, PrimaryMetricGoal\n",
|
||||
|
@ -186,7 +187,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"execution_count": 12,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
@ -240,7 +241,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -283,11 +284,11 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 19,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"BASE_DATA_PATH = '..\\..\\data'"
|
||||
"BASE_DATA_PATH = '../../data'"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -299,11 +300,194 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 22,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>gold_label</th>\n",
|
||||
" <th>sentence1_binary_parse</th>\n",
|
||||
" <th>sentence2_binary_parse</th>\n",
|
||||
" <th>sentence1_parse</th>\n",
|
||||
" <th>sentence2_parse</th>\n",
|
||||
" <th>sentence1</th>\n",
|
||||
" <th>sentence2</th>\n",
|
||||
" <th>captionID</th>\n",
|
||||
" <th>pairID</th>\n",
|
||||
" <th>label1</th>\n",
|
||||
" <th>label2</th>\n",
|
||||
" <th>label3</th>\n",
|
||||
" <th>label4</th>\n",
|
||||
" <th>label5</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>neutral</td>\n",
|
||||
" <td>( ( ( A person ) ( on ( a horse ) ) ) ( ( jump...</td>\n",
|
||||
" <td>( ( A person ) ( ( is ( ( training ( his horse...</td>\n",
|
||||
" <td>(ROOT (S (NP (NP (DT A) (NN person)) (PP (IN o...</td>\n",
|
||||
" <td>(ROOT (S (NP (DT A) (NN person)) (VP (VBZ is) ...</td>\n",
|
||||
" <td>A person on a horse jumps over a broken down a...</td>\n",
|
||||
" <td>A person is training his horse for a competition.</td>\n",
|
||||
" <td>3416050480.jpg#4</td>\n",
|
||||
" <td>3416050480.jpg#4r1n</td>\n",
|
||||
" <td>neutral</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>contradiction</td>\n",
|
||||
" <td>( ( ( A person ) ( on ( a horse ) ) ) ( ( jump...</td>\n",
|
||||
" <td>( ( A person ) ( ( ( ( is ( at ( a diner ) ) )...</td>\n",
|
||||
" <td>(ROOT (S (NP (NP (DT A) (NN person)) (PP (IN o...</td>\n",
|
||||
" <td>(ROOT (S (NP (DT A) (NN person)) (VP (VBZ is) ...</td>\n",
|
||||
" <td>A person on a horse jumps over a broken down a...</td>\n",
|
||||
" <td>A person is at a diner, ordering an omelette.</td>\n",
|
||||
" <td>3416050480.jpg#4</td>\n",
|
||||
" <td>3416050480.jpg#4r1c</td>\n",
|
||||
" <td>contradiction</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>entailment</td>\n",
|
||||
" <td>( ( ( A person ) ( on ( a horse ) ) ) ( ( jump...</td>\n",
|
||||
" <td>( ( A person ) ( ( ( ( is outdoors ) , ) ( on ...</td>\n",
|
||||
" <td>(ROOT (S (NP (NP (DT A) (NN person)) (PP (IN o...</td>\n",
|
||||
" <td>(ROOT (S (NP (DT A) (NN person)) (VP (VBZ is) ...</td>\n",
|
||||
" <td>A person on a horse jumps over a broken down a...</td>\n",
|
||||
" <td>A person is outdoors, on a horse.</td>\n",
|
||||
" <td>3416050480.jpg#4</td>\n",
|
||||
" <td>3416050480.jpg#4r1e</td>\n",
|
||||
" <td>entailment</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>neutral</td>\n",
|
||||
" <td>( Children ( ( ( smiling and ) waving ) ( at c...</td>\n",
|
||||
" <td>( They ( are ( smiling ( at ( their parents ) ...</td>\n",
|
||||
" <td>(ROOT (NP (S (NP (NNP Children)) (VP (VBG smil...</td>\n",
|
||||
" <td>(ROOT (S (NP (PRP They)) (VP (VBP are) (VP (VB...</td>\n",
|
||||
" <td>Children smiling and waving at camera</td>\n",
|
||||
" <td>They are smiling at their parents</td>\n",
|
||||
" <td>2267923837.jpg#2</td>\n",
|
||||
" <td>2267923837.jpg#2r1n</td>\n",
|
||||
" <td>neutral</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>entailment</td>\n",
|
||||
" <td>( Children ( ( ( smiling and ) waving ) ( at c...</td>\n",
|
||||
" <td>( There ( ( are children ) present ) )</td>\n",
|
||||
" <td>(ROOT (NP (S (NP (NNP Children)) (VP (VBG smil...</td>\n",
|
||||
" <td>(ROOT (S (NP (EX There)) (VP (VBP are) (NP (NN...</td>\n",
|
||||
" <td>Children smiling and waving at camera</td>\n",
|
||||
" <td>There are children present</td>\n",
|
||||
" <td>2267923837.jpg#2</td>\n",
|
||||
" <td>2267923837.jpg#2r1e</td>\n",
|
||||
" <td>entailment</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" gold_label sentence1_binary_parse \\\n",
|
||||
"0 neutral ( ( ( A person ) ( on ( a horse ) ) ) ( ( jump... \n",
|
||||
"1 contradiction ( ( ( A person ) ( on ( a horse ) ) ) ( ( jump... \n",
|
||||
"2 entailment ( ( ( A person ) ( on ( a horse ) ) ) ( ( jump... \n",
|
||||
"3 neutral ( Children ( ( ( smiling and ) waving ) ( at c... \n",
|
||||
"4 entailment ( Children ( ( ( smiling and ) waving ) ( at c... \n",
|
||||
"\n",
|
||||
" sentence2_binary_parse \\\n",
|
||||
"0 ( ( A person ) ( ( is ( ( training ( his horse... \n",
|
||||
"1 ( ( A person ) ( ( ( ( is ( at ( a diner ) ) )... \n",
|
||||
"2 ( ( A person ) ( ( ( ( is outdoors ) , ) ( on ... \n",
|
||||
"3 ( They ( are ( smiling ( at ( their parents ) ... \n",
|
||||
"4 ( There ( ( are children ) present ) ) \n",
|
||||
"\n",
|
||||
" sentence1_parse \\\n",
|
||||
"0 (ROOT (S (NP (NP (DT A) (NN person)) (PP (IN o... \n",
|
||||
"1 (ROOT (S (NP (NP (DT A) (NN person)) (PP (IN o... \n",
|
||||
"2 (ROOT (S (NP (NP (DT A) (NN person)) (PP (IN o... \n",
|
||||
"3 (ROOT (NP (S (NP (NNP Children)) (VP (VBG smil... \n",
|
||||
"4 (ROOT (NP (S (NP (NNP Children)) (VP (VBG smil... \n",
|
||||
"\n",
|
||||
" sentence2_parse \\\n",
|
||||
"0 (ROOT (S (NP (DT A) (NN person)) (VP (VBZ is) ... \n",
|
||||
"1 (ROOT (S (NP (DT A) (NN person)) (VP (VBZ is) ... \n",
|
||||
"2 (ROOT (S (NP (DT A) (NN person)) (VP (VBZ is) ... \n",
|
||||
"3 (ROOT (S (NP (PRP They)) (VP (VBP are) (VP (VB... \n",
|
||||
"4 (ROOT (S (NP (EX There)) (VP (VBP are) (NP (NN... \n",
|
||||
"\n",
|
||||
" sentence1 \\\n",
|
||||
"0 A person on a horse jumps over a broken down a... \n",
|
||||
"1 A person on a horse jumps over a broken down a... \n",
|
||||
"2 A person on a horse jumps over a broken down a... \n",
|
||||
"3 Children smiling and waving at camera \n",
|
||||
"4 Children smiling and waving at camera \n",
|
||||
"\n",
|
||||
" sentence2 captionID \\\n",
|
||||
"0 A person is training his horse for a competition. 3416050480.jpg#4 \n",
|
||||
"1 A person is at a diner, ordering an omelette. 3416050480.jpg#4 \n",
|
||||
"2 A person is outdoors, on a horse. 3416050480.jpg#4 \n",
|
||||
"3 They are smiling at their parents 2267923837.jpg#2 \n",
|
||||
"4 There are children present 2267923837.jpg#2 \n",
|
||||
"\n",
|
||||
" pairID label1 label2 label3 label4 label5 \n",
|
||||
"0 3416050480.jpg#4r1n neutral NaN NaN NaN NaN \n",
|
||||
"1 3416050480.jpg#4r1c contradiction NaN NaN NaN NaN \n",
|
||||
"2 3416050480.jpg#4r1e entailment NaN NaN NaN NaN \n",
|
||||
"3 2267923837.jpg#2r1n neutral NaN NaN NaN NaN \n",
|
||||
"4 2267923837.jpg#2r1e entailment NaN NaN NaN NaN "
|
||||
]
|
||||
},
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# defaults to txt\n",
|
||||
"train = snli.load_pandas_df(BASE_DATA_PATH, file_split=\"train\")\n",
|
||||
|
@ -326,9 +510,91 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>score</th>\n",
|
||||
" <th>sentence1</th>\n",
|
||||
" <th>sentence2</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>neutral</td>\n",
|
||||
" <td>A person on a horse jumps over a broken down a...</td>\n",
|
||||
" <td>A person is training his horse for a competition.</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>contradiction</td>\n",
|
||||
" <td>A person on a horse jumps over a broken down a...</td>\n",
|
||||
" <td>A person is at a diner, ordering an omelette.</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>entailment</td>\n",
|
||||
" <td>A person on a horse jumps over a broken down a...</td>\n",
|
||||
" <td>A person is outdoors, on a horse.</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>neutral</td>\n",
|
||||
" <td>Children smiling and waving at camera</td>\n",
|
||||
" <td>They are smiling at their parents</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>entailment</td>\n",
|
||||
" <td>Children smiling and waving at camera</td>\n",
|
||||
" <td>There are children present</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" score sentence1 \\\n",
|
||||
"0 neutral A person on a horse jumps over a broken down a... \n",
|
||||
"1 contradiction A person on a horse jumps over a broken down a... \n",
|
||||
"2 entailment A person on a horse jumps over a broken down a... \n",
|
||||
"3 neutral Children smiling and waving at camera \n",
|
||||
"4 entailment Children smiling and waving at camera \n",
|
||||
"\n",
|
||||
" sentence2 \n",
|
||||
"0 A person is training his horse for a competition. \n",
|
||||
"1 A person is at a diner, ordering an omelette. \n",
|
||||
"2 A person is outdoors, on a horse. \n",
|
||||
"3 They are smiling at their parents \n",
|
||||
"4 There are children present "
|
||||
]
|
||||
},
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def clean(df, file_split):\n",
|
||||
" src_file_path = os.path.join(BASE_DATA_PATH, \"raw/snli_1.0/snli_1.0_{}.txt\".format(file_split))\n",
|
||||
|
@ -355,7 +621,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 24,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
@ -376,11 +642,22 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 25,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'../../data\\\\clean/snli_1.0'"
|
||||
]
|
||||
},
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"gensen_preprocess(train_tok, dev_tok, test_tok, BASE_DATA_PATH)"
|
||||
]
|
||||
|
@ -404,16 +681,16 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data_folder = os.path.join(BASE_DATA_PATH, \"clean\\snli_1.0\")"
|
||||
"data_folder = os.path.join(BASE_DATA_PATH, \"clean/snli_1.0\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -442,11 +719,22 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"$AZUREML_DATAREFERENCE_6faee69b569b4268b8bf027b0bb4fd73"
|
||||
]
|
||||
},
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"ds.upload(src_dir=data_folder, target_path=\"data/processed\", overwrite=True, show_progress=True)"
|
||||
"ds.upload(src_dir=data_folder, target_path=\"data/processed\", overwrite=True, show_progress=False)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -480,7 +768,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 128,
|
||||
"execution_count": 30,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -488,13 +776,13 @@
|
|||
"output_type": "stream",
|
||||
"text": [
|
||||
"Found existing compute target.\n",
|
||||
"{'currentNodeCount': 0, 'targetNodeCount': 0, 'nodeStateCounts': {'preparingNodeCount': 0, 'runningNodeCount': 0, 'idleNodeCount': 0, 'unusableNodeCount': 0, 'leavingNodeCount': 0, 'preemptedNodeCount': 0}, 'allocationState': 'Steady', 'allocationStateTransitionTime': '2019-06-11T22:30:48.768000+00:00', 'errors': None, 'creationTime': '2019-05-20T22:09:40.142683+00:00', 'modifiedTime': '2019-05-20T22:10:11.888950+00:00', 'provisioningState': 'Succeeded', 'provisioningStateTransitionTime': None, 'scaleSettings': {'minNodeCount': 0, 'maxNodeCount': 4, 'nodeIdleTimeBeforeScaleDown': 'PT120S'}, 'vmPriority': 'Dedicated', 'vmSize': 'STANDARD_NC6'}\n"
|
||||
"{'currentNodeCount': 0, 'targetNodeCount': 0, 'nodeStateCounts': {'preparingNodeCount': 0, 'runningNodeCount': 0, 'idleNodeCount': 0, 'unusableNodeCount': 0, 'leavingNodeCount': 0, 'preemptedNodeCount': 0}, 'allocationState': 'Steady', 'allocationStateTransitionTime': '2019-06-14T20:39:31.676000+00:00', 'errors': None, 'creationTime': '2019-06-03T21:18:34.507970+00:00', 'modifiedTime': '2019-06-03T21:18:50.790782+00:00', 'provisioningState': 'Succeeded', 'provisioningStateTransitionTime': None, 'scaleSettings': {'minNodeCount': 0, 'maxNodeCount': 8, 'nodeIdleTimeBeforeScaleDown': 'PT120S'}, 'vmPriority': 'Dedicated', 'vmSize': 'STANDARD_NC6'}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# choose a name for your cluster\n",
|
||||
"cluster_name = \"gpucluster\"\n",
|
||||
"cluster_name = \"gpugensen\"\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" compute_target = ComputeTarget(workspace=ws, name=cluster_name)\n",
|
||||
|
@ -502,7 +790,7 @@
|
|||
"except ComputeTargetException:\n",
|
||||
" print('Creating a new compute target...')\n",
|
||||
" compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_NC6',\n",
|
||||
" max_nodes=4)\n",
|
||||
" max_nodes=8)\n",
|
||||
"\n",
|
||||
" # create the cluster\n",
|
||||
" compute_target = ComputeTarget.create(ws, cluster_name, compute_config)\n",
|
||||
|
@ -520,12 +808,12 @@
|
|||
"## 2.2 Access to a Project Directory\n",
|
||||
"In this section, we set the GenSen code folder and data folder for training. Create a directory that will contain all the necessary code from your local machine that you will need access to on the remote resource. This includes the training script and any additional files your training script depends on.\n",
|
||||
"\n",
|
||||
"`project_folder` contains all the code you want to submit to AmlCompute to run. The size of the folder can not exceed 300Mb. In GenSen model, it loads large pre-trained embedding files to the model. Thus, we need to save large files in datastore and only upload code to `project_folder`."
|
||||
"`project_folder` contains all the code you want to submit to AmlCompute to run. The size of the folder can not exceed 300Mb. In GenSen model, it loads large pre-trained embedding files to the model. Thus, we need to save large files in datastore and only upload code to `project_folder`. We set the gensen project folder under `utils_nlp`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"execution_count": 31,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
@ -562,6 +850,37 @@
|
|||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Once your script is ready, copy the training script `gensen_train.py` and config file `gensen_config.json` into the project directory."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'../../utils_nlp/gensen/gensen_config.json'"
|
||||
]
|
||||
},
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import shutil\n",
|
||||
"\n",
|
||||
"gensen_folder = os.path.join(project_folder,'utils_nlp/gensen/')\n",
|
||||
"shutil.copy('gensen_train.py', gensen_folder)\n",
|
||||
"shutil.copy('gensen_config.json', gensen_folder)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
|
@ -572,7 +891,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
@ -592,21 +911,29 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 129,
|
||||
"execution_count": 34,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"WARNING - framework_version is not specified, defaulting to version 1.1.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"script_params = {\n",
|
||||
" '--config': 'utils_nlp/model/gensen/sample_config.json',\n",
|
||||
" '--config': 'utils_nlp/gensen/gensen_config.json',\n",
|
||||
" '--data_folder': ws.get_default_datastore().as_mount()}\n",
|
||||
"\n",
|
||||
"estimator = PyTorch(source_directory=project_folder,\n",
|
||||
" script_params=script_params,\n",
|
||||
" compute_target=compute_target,\n",
|
||||
" entry_script='utils_nlp/model/gensen/train.py',\n",
|
||||
" entry_script='utils_nlp/gensen/gensen_train.py',\n",
|
||||
" node_count=4,\n",
|
||||
" process_count_per_node=1,\n",
|
||||
" distributed_backend='mpi',\n",
|
||||
" distributed_training=MpiConfiguration(),\n",
|
||||
" use_gpu=True,\n",
|
||||
" conda_packages=['scikit-learn=0.20.3', 'h5py', 'nltk']\n",
|
||||
" )"
|
||||
|
@ -641,19 +968,26 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 125,
|
||||
"execution_count": 38,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Submitting C:\\Users\\lishao\\Project\\Rotation2\\NLP directory for run. The size of the directory >= 25 MB, so it can take a few minutes.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Run(Experiment: pytorch-gensen,\n",
|
||||
"Id: pytorch-gensen_1560462957_9acd9ecd,\n",
|
||||
"Id: pytorch-gensen_1560797674_e36e44f4,\n",
|
||||
"Type: azureml.scriptrun,\n",
|
||||
"Status: Queued)\n"
|
||||
"Status: Preparing)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -698,7 +1032,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 123,
|
||||
"execution_count": 39,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
@ -706,7 +1040,7 @@
|
|||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "832324235dc3438782dd1deb056f013e",
|
||||
"model_id": "19d55fcc0871444da604b1d828d9eac4",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
{
|
||||
"training": {
|
||||
"optimizer": "adam",
|
||||
"clip_c": 1,
|
||||
"lrate": 0.0001,
|
||||
"batch_size": 16,
|
||||
"n_gpus": 1,
|
||||
"stop_patience": 2
|
||||
},
|
||||
"management": {
|
||||
"monitor_loss": 9600,
|
||||
"print_samples": 12800,
|
||||
"checkpoint_freq": 480000,
|
||||
"eval_freq": 4800000
|
||||
},
|
||||
"data": {"paths": [
|
||||
{
|
||||
"train_src": "data/corpora/nmt/training/train.nmt.de-en.en.tok",
|
||||
"train_trg": "data/corpora/nmt/training/train.nmt.de-en.de.tok",
|
||||
"val_src": "data/corpora/nmt/training/dev.nmt.de-en.en.tok",
|
||||
"val_trg": "data/corpora/nmt/training/dev.nmt.de-en.de.tok",
|
||||
"taskname": "de-en"
|
||||
},
|
||||
{
|
||||
"train_src": "data/corpora/nmt/training/train.nmt.fr-en.en.tok",
|
||||
"train_trg": "data/corpora/nmt/training/train.nmt.fr-en.fr.tok",
|
||||
"val_src": "data/corpora/nmt/training/dev.nmt.fr-en.en.tok",
|
||||
"val_trg": "data/corpora/nmt/training/dev.nmt.fr-en.fr.tok",
|
||||
"taskname": "fr-en"
|
||||
}
|
||||
],
|
||||
"max_src_length": 90,
|
||||
"max_trg_length": 90,
|
||||
"task": "multi-seq2seq-nli",
|
||||
"save_dir": "data/models/example",
|
||||
"nli_train": "data/corpora/allnli.train.txt.clean.noblank",
|
||||
"nli_dev": "data/corpora/snli_1.0_dev.txt.clean.noblank",
|
||||
"nli_test": "data/corpora/snli_1.0_test.txt.clean.noblank"
|
||||
},
|
||||
"model": {
|
||||
"dim_src": 2048,
|
||||
"dim_trg": 2048,
|
||||
"dim_word_src": 512,
|
||||
"dim_word_trg": 512,
|
||||
"n_words_src": 80000,
|
||||
"n_words_trg": 30000,
|
||||
"n_layers_src": 1,
|
||||
"bidirectional": true,
|
||||
"layernorm": false,
|
||||
"dropout": 0.8
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче