Files
wehub-resource-sync 593b94c120
pytest / Unit Tests (push) Has been cancelled
pytest / Integration (integration_tests_a) (push) Has been cancelled
pytest / Integration (integration_tests_b) (push) Has been cancelled
pytest / Integration (integration_tests_c) (push) Has been cancelled
pytest / Integration (integration_tests_d) (push) Has been cancelled
pytest / Integration (integration_tests_e) (push) Has been cancelled
pytest / Integration (integration_tests_f) (push) Has been cancelled
pytest / Integration (integration_tests_g) (push) Has been cancelled
pytest / Integration (integration_tests_h) (push) Has been cancelled
pytest / Integration (integration_tests_i) (push) Has been cancelled
pytest / Integration (integration_tests_j) (push) Has been cancelled
pytest / Distributed (distributed_a) (push) Has been cancelled
pytest / Distributed (distributed_b) (push) Has been cancelled
pytest / Distributed (distributed_c) (push) Has been cancelled
pytest / Distributed (distributed_d) (push) Has been cancelled
pytest / Distributed (distributed_e) (push) Has been cancelled
pytest / Distributed (distributed_f) (push) Has been cancelled
pytest / Minimal Install (push) Has been cancelled
pytest / Event File (push) Has been cancelled
pytest (slow) / py-slow (push) Has been cancelled
Publish JSON Schema / publish-schema (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:49:20 +08:00

36 lines
1.0 KiB
Python

#!/usr/bin/env python
# # Simple Model Training Example
#
# This example is the API example for this Ludwig command line example
# (https://ludwig-ai.github.io/ludwig-docs/latest/examples/mnist/).
import logging
import shutil
import yaml
from ludwig.api import LudwigModel
from ludwig.datasets import mnist
# clean out prior results
shutil.rmtree("./results", ignore_errors=True)
# set up Python dictionary to hold model training parameters
with open("./config.yaml") as f:
config = yaml.safe_load(f.read())
# Define Ludwig model object that drive model training
model = LudwigModel(config, logging_level=logging.INFO)
# load and split MNIST dataset
training_set, test_set, _ = mnist.load(split=True)
# initiate model training
train_stats, _, output_directory = model.train( # training statistics # location for training results saved to disk
training_set=training_set,
test_set=test_set,
experiment_name="simple_image_experiment",
model_name="single_model",
skip_save_processed_input=True,
)