tahamajs's picture
download
raw
2.77 kB
import yaml
import os
from typing import Dict, Any, Optional
def load_config(config_path: str = "config.yaml") -> Dict[str, Any]:
if not os.path.exists(config_path):
return get_default_config()
with open(config_path, "r") as file:
config = yaml.safe_load(file)
return config
def get_default_config() -> Dict[str, Any]:
return {
"model": {
"neural": {
"embedding_dim": 512,
"hidden_dim": 1024,
"num_layers": 6,
"num_heads": 8,
"dropout": 0.1,
"vocab_size": 10000,
"max_sequence_length": 512,
},
"geometric": {
"point_embedding_dim": 128,
"relation_embedding_dim": 64,
"max_objects": 100,
"coordinate_precision": 6,
},
"proof": {
"max_steps": 20,
"beam_width": 5,
"temperature": 0.7,
"top_k": 50,
"top_p": 0.9,
},
},
"training": {
"batch_size": 32,
"learning_rate": 1e-4,
"weight_decay": 1e-5,
"warmup_steps": 1000,
"max_epochs": 100,
"gradient_clip_val": 1.0,
"patience": 10,
},
"solver": {
"strategies": {
"neural": {"enabled": True, "weight": 0.4, "timeout": 30},
"coordinate": {"enabled": True, "weight": 0.3, "timeout": 20},
"synthetic": {"enabled": True, "weight": 0.2, "timeout": 25},
"hybrid": {"enabled": True, "weight": 0.1, "timeout": 45},
},
"verification": {
"enabled": True,
"strict_mode": False,
"cross_check": True,
},
},
"system": {
"device": "auto",
"num_workers": 4,
"pin_memory": True,
"logging": {
"level": "INFO",
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
},
"seed": 42,
"deterministic": True,
},
"paths": {
"data_dir": "data/",
"results_dir": "results/",
"models_dir": "models/",
"logs_dir": "logs/",
"cache_dir": ".cache/",
},
}
def save_config(config: Dict[str, Any], config_path: str = "config.yaml"):
config_dir = os.path.dirname(config_path)
if config_dir and not os.path.exists(config_dir):
os.makedirs(config_dir)
with open(config_path, "w") as file:
yaml.dump(config, file, default_flow_style=False, indent=2)

Xet Storage Details

Size:
2.77 kB
·
Xet hash:
66983e78edb7b45b4043228e295e70436f509c8fc9a444368e061ed0f614edcc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.