Spaces:
Runtime error
Runtime error
| # train.py | |
| import time | |
| import yaml | |
| def train_model(config_file="train.yaml"): | |
| print("π§ Starting training...") | |
| try: | |
| with open(config_file, "r") as f: | |
| config = yaml.safe_load(f) | |
| except Exception as e: | |
| print("β οΈ Failed to load config:", str(e)) | |
| return f"β Failed to load config: {str(e)}" | |
| model_name = config.get("model", {}).get("name", "default_model") | |
| epochs = config.get("training", {}).get("epochs", 5) | |
| lr = config.get("training", {}).get("learning_rate", 0.001) | |
| batch_size = config.get("training", {}).get("batch_size", 32) | |
| device = config.get("training", {}).get("device", "cpu") | |
| print(f"π¦ Model: {model_name}") | |
| print(f"π§ Device: {device}") | |
| print(f"π Epochs: {epochs}, Batch Size: {batch_size}, Learning Rate: {lr}") | |
| for epoch in range(1, epochs + 1): | |
| print(f"π Epoch {epoch}/{epochs} ...") | |
| time.sleep(1) # Simulate work | |
| print("β Training complete.") | |
| return f"β Dummy training for `{model_name}` finished on `{device}`!" | |