-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (20 loc) · 869 Bytes
/
Copy pathutils.py
File metadata and controls
25 lines (20 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import importlib
from config import GSASRecExperimentConfig
from dataset_utils import get_num_items
import torch
from gsasrec import GSASRec
def load_config(config_file: str) -> GSASRecExperimentConfig:
spec = importlib.util.spec_from_file_location("config", config_file)
config_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(config_module)
return config_module.config
def build_model(config: GSASRecExperimentConfig):
num_items = get_num_items(config.dataset_name)
model = GSASRec(num_items, sequence_length=config.sequence_length, embedding_dim=config.embedding_dim,
num_heads=config.num_heads, num_blocks=config.num_blocks, dropout_rate=config.dropout_rate)
return model
def get_device():
device = "cpu"
if torch.cuda.is_available():
device="cuda:0"
return device