-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,345 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"name": "main_knapsack.ipynb", | ||
"provenance": [], | ||
"collapsed_sections": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
}, | ||
"accelerator": "GPU" | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "yz0obxlhdAoH", | ||
"colab_type": "code", | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 34 | ||
}, | ||
"outputId": "153bf5d4-c3e2-43e2-8619-424b0edaba9d" | ||
}, | ||
"source": [ | ||
"" | ||
], | ||
"execution_count": null, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"text": [ | ||
"Mounted at /content/gdrive\n" | ||
], | ||
"name": "stdout" | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "ir7Jh4n_fjNJ", | ||
"colab_type": "code", | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 34 | ||
}, | ||
"outputId": "da454546-471a-4eba-b756-245bc54e92a4" | ||
}, | ||
"source": [ | ||
"%cd \"CD into the main directory\"" | ||
], | ||
"execution_count": null, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"text": [ | ||
"/content/drive/My Drive/Colab Notebooks/attention-learn-to-route-master\n" | ||
], | ||
"name": "stdout" | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "ka4Ko0ijhKq2", | ||
"colab_type": "code", | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 85 | ||
}, | ||
"outputId": "ec9a3d5d-7e69-42e8-ea7a-638679ce70d0" | ||
}, | ||
"source": [ | ||
"!ls" | ||
], | ||
"execution_count": null, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"text": [ | ||
"environment.yml knapsack.ipynb plot_vrp.ipynb reinforce_baselines.py utils\n", | ||
"eval.py\t\t LICENSE\t pretrained\t run.py\n", | ||
"generate_data.py nets\t\t problems\t simple_tsp.ipynb\n", | ||
"images\t\t options.py\t README.md\t train.py\n" | ||
], | ||
"name": "stdout" | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "ll_VsNSzEnng", | ||
"colab_type": "code", | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 207 | ||
}, | ||
"outputId": "20902310-24ba-4982-bc67-24b4117426af" | ||
}, | ||
"source": [ | ||
"pip install tensorboard_logger" | ||
], | ||
"execution_count": null, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"text": [ | ||
"Collecting tensorboard_logger\n", | ||
" Downloading https://files.pythonhosted.org/packages/87/7a/ec0fd26dba69191f82eb8f38f5b401c124f45a207490a7ade6ea9717ecdb/tensorboard_logger-0.1.0-py2.py3-none-any.whl\n", | ||
"Requirement already satisfied: protobuf in /usr/local/lib/python3.6/dist-packages (from tensorboard_logger) (3.12.4)\n", | ||
"Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from tensorboard_logger) (1.15.0)\n", | ||
"Requirement already satisfied: scipy>=0.19.1 in /usr/local/lib/python3.6/dist-packages (from tensorboard_logger) (1.4.1)\n", | ||
"Requirement already satisfied: pillow>=4.1.1 in /usr/local/lib/python3.6/dist-packages (from tensorboard_logger) (7.0.0)\n", | ||
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from tensorboard_logger) (1.18.5)\n", | ||
"Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf->tensorboard_logger) (49.6.0)\n", | ||
"Installing collected packages: tensorboard-logger\n", | ||
"Successfully installed tensorboard-logger-0.1.0\n" | ||
], | ||
"name": "stdout" | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "2EgepI9oaVG5", | ||
"colab_type": "code", | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 1000 | ||
}, | ||
"outputId": "5d49c910-a209-4040-952e-778d13f40c65" | ||
}, | ||
"source": [ | ||
"!python run.py --graph_size 20 --baseline rollout --run_name 'knapsack' --problem 'cvrp'\n" | ||
], | ||
"execution_count": null, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"text": [ | ||
"2020-08-26 15:05:08.687446: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1\n", | ||
"{'baseline': 'rollout',\n", | ||
" 'batch_size': 512,\n", | ||
" 'bl_alpha': 0.05,\n", | ||
" 'bl_warmup_epochs': 1,\n", | ||
" 'checkpoint_encoder': False,\n", | ||
" 'checkpoint_epochs': 1,\n", | ||
" 'data_distribution': None,\n", | ||
" 'embedding_dim': 128,\n", | ||
" 'epoch_size': 1280000,\n", | ||
" 'epoch_start': 0,\n", | ||
" 'eval_batch_size': 1024,\n", | ||
" 'eval_only': False,\n", | ||
" 'exp_beta': 0.8,\n", | ||
" 'graph_size': 20,\n", | ||
" 'hidden_dim': 128,\n", | ||
" 'load_path': None,\n", | ||
" 'log_dir': 'logs',\n", | ||
" 'log_step': 50,\n", | ||
" 'lr_critic': 0.0001,\n", | ||
" 'lr_decay': 1.0,\n", | ||
" 'lr_model': 0.0001,\n", | ||
" 'max_grad_norm': 1.0,\n", | ||
" 'model': 'attention',\n", | ||
" 'n_encode_layers': 3,\n", | ||
" 'n_epochs': 100,\n", | ||
" 'no_cuda': False,\n", | ||
" 'no_progress_bar': False,\n", | ||
" 'no_tensorboard': False,\n", | ||
" 'normalization': 'batch',\n", | ||
" 'output_dir': 'outputs',\n", | ||
" 'problem': 'cvrp',\n", | ||
" 'resume': None,\n", | ||
" 'run_name': 'knapsack_20200826T150517',\n", | ||
" 'save_dir': 'outputs/cvrp_20/knapsack_20200826T150517',\n", | ||
" 'seed': 1234,\n", | ||
" 'shrink_size': None,\n", | ||
" 'tanh_clipping': 10.0,\n", | ||
" 'use_cuda': True,\n", | ||
" 'val_dataset': None,\n", | ||
" 'val_size': 10000,\n", | ||
" 'weight_limit': 1000.0}\n", | ||
"Evaluating baseline model on evaluation dataset\n", | ||
"100% 10/10 [00:00<00:00, 12.28it/s]\n", | ||
"Start train epoch 0, lr=0.0001 for run knapsack_20200826T150517\n", | ||
" 0% 0/2500 [00:00<?, ?it/s]epoch: 0, train_batch_id: 0, avg_cost: 78.484375\n", | ||
"grad_norm: 166.310302734375, clipped: 1.0\n", | ||
" 2% 49/2500 [00:04<03:25, 11.94it/s]epoch: 0, train_batch_id: 50, avg_cost: 60.46875\n", | ||
"grad_norm: 71.88386535644531, clipped: 1.0\n", | ||
" 4% 99/2500 [00:08<03:19, 12.06it/s]epoch: 0, train_batch_id: 100, avg_cost: 59.662109375\n", | ||
"grad_norm: 115.6478500366211, clipped: 1.0\n", | ||
" 6% 149/2500 [00:12<03:15, 12.05it/s]epoch: 0, train_batch_id: 150, avg_cost: 59.96875\n", | ||
"grad_norm: 51.02729034423828, clipped: 1.0\n", | ||
" 8% 199/2500 [00:16<03:14, 11.84it/s]epoch: 0, train_batch_id: 200, avg_cost: 59.130859375\n", | ||
"grad_norm: 40.66415786743164, clipped: 1.0\n", | ||
" 10% 249/2500 [00:20<03:07, 12.01it/s]epoch: 0, train_batch_id: 250, avg_cost: 59.44140625\n", | ||
"grad_norm: 40.314754486083984, clipped: 1.0\n", | ||
" 12% 299/2500 [00:25<03:02, 12.07it/s]epoch: 0, train_batch_id: 300, avg_cost: 59.251953125\n", | ||
"grad_norm: 30.581932067871094, clipped: 1.0\n", | ||
" 14% 349/2500 [00:29<03:01, 11.83it/s]epoch: 0, train_batch_id: 350, avg_cost: 59.619140625\n", | ||
"grad_norm: 35.219818115234375, clipped: 1.0\n", | ||
" 16% 399/2500 [00:33<02:55, 11.98it/s]epoch: 0, train_batch_id: 400, avg_cost: 59.177734375\n", | ||
"grad_norm: 28.27816390991211, clipped: 1.0\n", | ||
" 18% 449/2500 [00:37<02:53, 11.84it/s]epoch: 0, train_batch_id: 450, avg_cost: 59.0234375\n", | ||
"grad_norm: 33.07552719116211, clipped: 1.0\n", | ||
" 20% 499/2500 [00:41<02:48, 11.85it/s]epoch: 0, train_batch_id: 500, avg_cost: 59.3984375\n", | ||
"grad_norm: 38.58601379394531, clipped: 1.0\n", | ||
" 22% 549/2500 [00:46<02:42, 12.02it/s]epoch: 0, train_batch_id: 550, avg_cost: 58.943359375\n", | ||
"grad_norm: 135.6937713623047, clipped: 1.0\n", | ||
" 24% 599/2500 [00:50<02:36, 12.13it/s]epoch: 0, train_batch_id: 600, avg_cost: 59.267578125\n", | ||
"grad_norm: 28.259641647338867, clipped: 1.0\n", | ||
" 26% 649/2500 [00:54<02:33, 12.06it/s]epoch: 0, train_batch_id: 650, avg_cost: 58.974609375\n", | ||
"grad_norm: 37.06266784667969, clipped: 1.0\n", | ||
" 28% 699/2500 [00:58<02:30, 11.94it/s]epoch: 0, train_batch_id: 700, avg_cost: 59.361328125\n", | ||
"grad_norm: 32.088584899902344, clipped: 1.0\n", | ||
" 30% 749/2500 [01:02<02:26, 11.99it/s]epoch: 0, train_batch_id: 750, avg_cost: 59.16796875\n", | ||
"grad_norm: 36.12895965576172, clipped: 1.0\n", | ||
" 32% 799/2500 [01:07<02:21, 12.03it/s]epoch: 0, train_batch_id: 800, avg_cost: 59.751953125\n", | ||
"grad_norm: 34.061378479003906, clipped: 1.0\n", | ||
" 34% 849/2500 [01:11<02:17, 12.02it/s]epoch: 0, train_batch_id: 850, avg_cost: 59.072265625\n", | ||
"grad_norm: 40.0155029296875, clipped: 1.0\n", | ||
" 36% 899/2500 [01:15<02:13, 11.98it/s]epoch: 0, train_batch_id: 900, avg_cost: 59.1328125\n", | ||
"grad_norm: 46.79561996459961, clipped: 1.0\n", | ||
" 38% 949/2500 [01:19<02:10, 11.87it/s]epoch: 0, train_batch_id: 950, avg_cost: 59.318359375\n", | ||
"grad_norm: 41.279022216796875, clipped: 1.0\n", | ||
" 40% 999/2500 [01:23<02:04, 12.06it/s]epoch: 0, train_batch_id: 1000, avg_cost: 59.14453125\n", | ||
"grad_norm: 26.266651153564453, clipped: 1.0\n", | ||
" 42% 1049/2500 [01:27<02:00, 12.06it/s]epoch: 0, train_batch_id: 1050, avg_cost: 59.505859375\n", | ||
"grad_norm: 65.15604400634766, clipped: 1.0\n", | ||
" 44% 1099/2500 [01:32<01:57, 11.87it/s]epoch: 0, train_batch_id: 1100, avg_cost: 59.06640625\n", | ||
"grad_norm: 23.09366798400879, clipped: 1.0\n", | ||
" 46% 1149/2500 [01:36<01:53, 11.88it/s]epoch: 0, train_batch_id: 1150, avg_cost: 59.138671875\n", | ||
"grad_norm: 142.7276611328125, clipped: 1.0\n", | ||
" 48% 1199/2500 [01:40<01:49, 11.86it/s]epoch: 0, train_batch_id: 1200, avg_cost: 59.18359375\n", | ||
"grad_norm: 25.37990951538086, clipped: 1.0\n", | ||
" 50% 1249/2500 [01:44<01:43, 12.06it/s]epoch: 0, train_batch_id: 1250, avg_cost: 58.98828125\n", | ||
"grad_norm: 22.93010711669922, clipped: 1.0\n", | ||
" 52% 1299/2500 [01:48<01:40, 11.89it/s]epoch: 0, train_batch_id: 1300, avg_cost: 59.171875\n", | ||
"grad_norm: 22.098663330078125, clipped: 1.0\n", | ||
" 54% 1349/2500 [01:53<01:35, 12.11it/s]epoch: 0, train_batch_id: 1350, avg_cost: 58.91015625\n", | ||
"grad_norm: 77.44014739990234, clipped: 1.0\n", | ||
" 56% 1399/2500 [01:57<01:32, 11.92it/s]epoch: 0, train_batch_id: 1400, avg_cost: 59.142578125\n", | ||
"grad_norm: 36.251338958740234, clipped: 1.0\n", | ||
" 58% 1449/2500 [02:01<01:28, 11.85it/s]epoch: 0, train_batch_id: 1450, avg_cost: 59.4609375\n", | ||
"grad_norm: 49.106380462646484, clipped: 1.0\n", | ||
" 60% 1499/2500 [02:05<01:23, 12.02it/s]epoch: 0, train_batch_id: 1500, avg_cost: 58.296875\n", | ||
"grad_norm: 36.80266571044922, clipped: 1.0\n", | ||
" 62% 1549/2500 [02:09<01:20, 11.77it/s]epoch: 0, train_batch_id: 1550, avg_cost: 58.6640625\n", | ||
"grad_norm: 48.53337097167969, clipped: 1.0\n", | ||
" 64% 1599/2500 [02:14<01:16, 11.78it/s]epoch: 0, train_batch_id: 1600, avg_cost: 59.1484375\n", | ||
"grad_norm: 31.579193115234375, clipped: 1.0\n", | ||
" 66% 1649/2500 [02:18<01:10, 12.10it/s]epoch: 0, train_batch_id: 1650, avg_cost: 59.26953125\n", | ||
"grad_norm: 41.5389518737793, clipped: 1.0\n", | ||
" 68% 1699/2500 [02:22<01:06, 11.96it/s]epoch: 0, train_batch_id: 1700, avg_cost: 58.7890625\n", | ||
"grad_norm: 30.169328689575195, clipped: 1.0\n", | ||
" 70% 1749/2500 [02:26<01:03, 11.75it/s]epoch: 0, train_batch_id: 1750, avg_cost: 58.716796875\n", | ||
"grad_norm: 22.15031623840332, clipped: 1.0\n", | ||
" 72% 1799/2500 [02:30<00:58, 11.93it/s]epoch: 0, train_batch_id: 1800, avg_cost: 58.787109375\n", | ||
"grad_norm: 23.735645294189453, clipped: 1.0\n", | ||
" 74% 1849/2500 [02:35<00:55, 11.65it/s]epoch: 0, train_batch_id: 1850, avg_cost: 59.267578125\n", | ||
"grad_norm: 36.46788024902344, clipped: 1.0\n", | ||
" 76% 1899/2500 [02:39<00:50, 11.98it/s]epoch: 0, train_batch_id: 1900, avg_cost: 58.865234375\n", | ||
"grad_norm: 22.83550453186035, clipped: 1.0\n", | ||
" 78% 1949/2500 [02:43<00:46, 11.76it/s]epoch: 0, train_batch_id: 1950, avg_cost: 58.359375\n", | ||
"grad_norm: 21.059162139892578, clipped: 1.0\n", | ||
" 80% 1999/2500 [02:47<00:43, 11.65it/s]epoch: 0, train_batch_id: 2000, avg_cost: 58.14453125\n", | ||
"grad_norm: 17.824607849121094, clipped: 1.0\n", | ||
" 82% 2049/2500 [02:52<00:37, 11.90it/s]epoch: 0, train_batch_id: 2050, avg_cost: 59.140625\n", | ||
"grad_norm: 19.90622329711914, clipped: 1.0\n", | ||
" 84% 2099/2500 [02:56<00:33, 11.89it/s]epoch: 0, train_batch_id: 2100, avg_cost: 59.10546875\n", | ||
"grad_norm: 27.473634719848633, clipped: 1.0\n", | ||
" 86% 2149/2500 [03:00<00:29, 11.90it/s]epoch: 0, train_batch_id: 2150, avg_cost: 58.787109375\n", | ||
"grad_norm: 27.58763313293457, clipped: 1.0\n", | ||
" 88% 2199/2500 [03:04<00:25, 12.03it/s]epoch: 0, train_batch_id: 2200, avg_cost: 58.921875\n", | ||
"grad_norm: 29.029743194580078, clipped: 1.0\n", | ||
" 90% 2249/2500 [03:08<00:20, 11.95it/s]epoch: 0, train_batch_id: 2250, avg_cost: 58.884765625\n", | ||
"grad_norm: 28.392826080322266, clipped: 1.0\n", | ||
" 92% 2299/2500 [03:13<00:16, 11.94it/s]epoch: 0, train_batch_id: 2300, avg_cost: 59.138671875\n", | ||
"grad_norm: 18.297311782836914, clipped: 1.0\n", | ||
" 94% 2349/2500 [03:17<00:12, 11.94it/s]epoch: 0, train_batch_id: 2350, avg_cost: 58.56640625\n", | ||
"grad_norm: 20.29456329345703, clipped: 1.0\n", | ||
" 96% 2399/2500 [03:21<00:08, 11.75it/s]epoch: 0, train_batch_id: 2400, avg_cost: 58.986328125\n", | ||
"grad_norm: 24.457075119018555, clipped: 1.0\n", | ||
" 98% 2449/2500 [03:25<00:04, 12.08it/s]epoch: 0, train_batch_id: 2450, avg_cost: 58.8828125\n", | ||
"grad_norm: 23.6254940032959, clipped: 1.0\n", | ||
"100% 2500/2500 [03:30<00:00, 11.90it/s]\n", | ||
"Finished epoch 0, took 00:04:26 s\n", | ||
"Saving model and state...\n", | ||
"Validating...\n", | ||
"100% 10/10 [00:00<00:00, 23.17it/s]\n", | ||
"Validation overall avg_cost: 58.849700927734375 +- 0.07074497640132904\n", | ||
"Evaluating candidate model on evaluation dataset\n", | ||
"100% 10/10 [00:00<00:00, 23.26it/s]\n", | ||
"Epoch 0 candidate mean 58.8848991394043, baseline epoch 0 mean 74.36969757080078, difference -15.484798431396484\n", | ||
"p-value: 0.0\n", | ||
"Update baseline\n", | ||
"Evaluating baseline model on evaluation dataset\n", | ||
"100% 10/10 [00:00<00:00, 23.42it/s]\n", | ||
"Set warmup alpha = 1.0\n", | ||
"Start train epoch 1, lr=0.0001 for run knapsack_20200826T150517\n", | ||
"Evaluating baseline on dataset...\n", | ||
"100% 1250/1250 [00:54<00:00, 22.78it/s]\n", | ||
" 0% 0/2500 [00:00<?, ?it/s]epoch: 1, train_batch_id: 0, avg_cost: 59.216796875\n", | ||
"grad_norm: 19.438228607177734, clipped: 1.0\n", | ||
" 2% 49/2500 [00:06<06:55, 5.90it/s]epoch: 1, train_batch_id: 50, avg_cost: 59.056640625\n", | ||
"grad_norm: 12.944281578063965, clipped: 1.0\n", | ||
" 4% 99/2500 [00:10<03:19, 12.03it/s]epoch: 1, train_batch_id: 100, avg_cost: 58.84375\n", | ||
"grad_norm: 11.414551734924316, clipped: 1.0\n", | ||
" 6% 149/2500 [00:14<03:17, 11.90it/s]epoch: 1, train_batch_id: 150, avg_cost: 58.513671875\n", | ||
"grad_norm: 12.289629936218262, clipped: 1.0\n", | ||
" 8% 199/2500 [00:19<03:16, 11.71it/s]epoch: 1, train_batch_id: 200, avg_cost: 58.634765625\n", | ||
"grad_norm: 13.104487419128418, clipped: 1.0\n", | ||
" 10% 249/2500 [00:23<03:12, 11.72it/s]epoch: 1, train_batch_id: 250, avg_cost: 58.4140625\n", | ||
"grad_norm: 20.398256301879883, clipped: 1.0\n", | ||
" 12% 299/2500 [00:27<03:05, 11.86it/s]epoch: 1, train_batch_id: 300, avg_cost: 58.748046875\n", | ||
"grad_norm: 20.47847557067871, clipped: 1.0\n", | ||
" 14% 349/2500 [00:31<03:04, 11.64it/s]epoch: 1, train_batch_id: 350, avg_cost: 58.244140625\n", | ||
"grad_norm: 13.327790260314941, clipped: 1.0\n", | ||
" 16% 399/2500 [00:36<02:59, 11.74it/s]epoch: 1, train_batch_id: 400, avg_cost: 58.744140625\n", | ||
"grad_norm: 26.23626136779785, clipped: 1.0\n", | ||
" 18% 449/2500 [00:40<02:55, 11.68it/s]epoch: 1, train_batch_id: 450, avg_cost: 58.984375\n", | ||
"grad_norm: 19.368364334106445, clipped: 1.0\n", | ||
" 20% 499/2500 [00:44<02:48, 11.91it/s]epoch: 1, train_batch_id: 500, avg_cost: 58.12109375\n", | ||
"grad_norm: 16.70184898376465, clipped: 1.0\n", | ||
" 22% 549/2500 [00:48<02:43, 11.92it/s]epoch: 1, train_batch_id: 550, avg_cost: 58.677734375\n", | ||
"grad_norm: 13.67425537109375, clipped: 1.0\n", | ||
" 24% 599/2500 [00:52<02:39, 11.90it/s]epoch: 1, train_batch_id: 600, avg_cost: 58.28125\n", | ||
"grad_norm: 16.817825317382812, clipped: 1.0\n", | ||
" 26% 649/2500 [00:57<02:38, 11.70it/s]epoch: 1, train_batch_id: 650, avg_cost: 58.619140625\n", | ||
"grad_norm: 17.675806045532227, clipped: 1.0\n", | ||
" 27% 683/2500 [01:00<02:33, 11.85it/s]" | ||
], | ||
"name": "stdout" | ||
} | ||
] | ||
} | ||
] | ||
} |