Beispiel #1
0
import numpy as np
import torch
import torch.optim as optim
from tensorboard_logger import configure, log_value
from torch.autograd.variable import Variable
from src.Utils import read_config
from src.Generator.generator import Generator
from src.Models.loss import losses_joint
from src.Models.models import CsgNet, ParseModelOutput
from src.Utils.learn_utils import LearningRate
from src.Utils.train_utils import prepare_input_op, Callbacks

import time

if len(sys.argv) > 1:
    config = read_config.Config(sys.argv[1])
else:
    config = read_config.Config("config.yml")

model_name = config.model_path.format(config.proportion, config.top_k,
                                      config.hidden_size, config.batch_size,
                                      config.optim, config.lr,
                                      config.weight_decay, config.dropout,
                                      "mix", config.mode)
print(config.config)

config.write_config("log/configs/{}_config.json".format(model_name))
configure("log/tensorboard/{}".format(model_name), flush_secs=5)

callback = Callbacks(config.batch_size, "log/db/{}".format(model_name))
callback.add_element(["train_loss", "test_loss", "train_mse", "test_mse"])
Beispiel #2
0
import torch
import torch.optim as optim
from torch.autograd.variable import Variable
from src.Utils import read_config
from src.Generator.shapenet_generator import get_shapenet_data
from src.Models.loss import losses_joint
from src.Models.models import CsgNet, ParseModelOutput
from src.Utils.learn_utils import LearningRate
from src.Utils.train_utils import prepare_input_op, Callbacks
import deepdish as dd
from torch.utils.data import DataLoader
from vis_voxels import vis_voxels

device = torch.device("cuda")

config = read_config.Config("config.yml")
with open("draws.txt", "r") as file:
    unique_draws = file.readlines()
unique_draws = [x.strip() for x in unique_draws]
primitives = dd.io.load('data/primitives.h5')
max_len = 7


def _col(samples):
    return samples


def get_csgnet():
    csgnet = CsgNet(grid_shape=[64, 64, 64],
                    dropout=config.dropout,
                    mode=config.mode,