# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.7.11 64-bit (''finderenv_new'': conda)'
#     name: python3
# ---

# # Graph Neural Network for multiscale solver in the Traveling Salesman Problem
#
# This notebook is designed to predict the edge's probability belongs to optimized solution. 
#
# In general, the input of GNN contains cooordinate($n_i \in R^{2}$), edges values(distance) and targeted edges, and meanwhile our GNN consists of $30$ graph convolutional layers and $3$ layers in MLP with hidden dimension $h=300$ for each layers.

# +
import os

import numpy as np

import torch
print(torch.cuda.is_available())
from config import *
from utils.process import *
# -

# ## 1. Set the model configuration parameters
#
# The cell below sets a number of parameters that define the model configuration. The parameters set here are being used both by the `get_config()` function.

# +
notebook_mode = True
viz_mode = False

# model-parameter
# config_path = "configs/tsp20.json"
config_path = "configs/tsp20.json"
config = get_config(config_path)


# -

# ## 2. Build or load the model
#
# You will want to execute either of the two code cells in the subsequent two sub-sections, not both.

# ### 2.1 Create a new model
#
# If you want to create a new model, this is the relevant section for you. If you want to load a previously saved model, skip ahead to section 2.2.

if viz_mode==False:

    # tsp20--model
    net = main(config, pretrained=False, patience=50, lr_scale=0.001, random_neighbor=False)

# ### 2.2 Load a saved model
#
# If you have previously created and saved a model and would now like to load it, simply execute the next code cell.

if viz_mode==False:

    # tsp20--model
    net = main(config, pretrained=True, patience=50,
               lr_scale=0.01, pretrained_path='./logs/tsp20/attgcn_preprocessor-2021-11-09 18:22:49/best_val_checkpoint.tar',
               random_neighbor=False)



StarcoderdataJupyterScriptsDedupFiltered