Python API reference¶
Modelling¶
- class pyaicad.Model[source]¶
A constraint satisfaction problem: variables with finite integer domains and constraints.
>>> m = Model() >>> grid = m.int_vars((2, 2), domain=range(1, 3)) # a 2 x 2 grid of variables >>> m.add(all_different(grid[0]), all_different([row[0] for row in grid]))
- int_vars(shape, domain)[source]¶
Variables sharing a domain.
shapeis a numbern, giving a list ofnvariables, or a tuple, giving nested lists:(9, 9)is a list of 9 rows of 9 variables.
- bool_vars(shape)[source]¶
Boolean variables, shaped like
int_vars().
- set_position(var, position)[source]¶
Attaches coordinates to a variable (a cell’s row and column, say).
Learned models can use them as positional information; they have no meaning for the constraints.
- add(*constraints)[source]¶
Adds constraints. Each argument is a constraint or an iterable of constraints.
- Parameters:
constraints (Constraint | Iterable[Constraint])
- Return type:
None
- property constraints: Tuple[Constraint, ...]¶
All the constraints, in the order they were added.
- is_constraint_satisfied(constraint, assignment)[source]¶
Whether
assignment(one value per variable) satisfies one constraint of the model.Iterate over
constraintsto find which ones an assignment violates.- Parameters:
constraint (Constraint)
- Return type:
- class pyaicad.Var(index, owner)[source]¶
A decision variable of a model. Created by
Model, never directly.var.indexis its position in an assignment.
- class pyaicad.Constraint[source]¶
A constraint, built by one of the functions below and added with
Model.add().scopeis the tuple of variables it constrains.
- pyaicad.all_different(variables)[source]¶
The variables take pairwise different values.
- Parameters:
- Return type:
- pyaicad.equal(x, value)[source]¶
xtakesvalue. Adding it to a model shrinks the domain ofxto that value.- Parameters:
- Return type:
- pyaicad.among(variables, values, lb, ub)[source]¶
Between
lbandubof the variables take a value invalues.
- pyaicad.at_least(variables, values, lb)[source]¶
At least
lbof the variables take a value invalues.
- pyaicad.sum_equals(variables, target)[source]¶
The variables add up to
target. Values may be negative.- Parameters:
- Return type:
- pyaicad.gcc(variables, bounds)[source]¶
Global cardinality: each value of
boundsoccurs between itsloandhitimes.boundsis either a mapping{value: (lo, hi)}or an iterable of(value, lo, hi). A value that is not inboundsis unconstrained.
- pyaicad.regular(variables, transitions, initial_state, accepting_states)[source]¶
The variables, read in order, form a word accepted by an automaton.
transitions[state][symbol]is the state reached fromstateon a symbol, orNoneif there is no transition. The columns are the sorted values found in the domains of the variables at the time the constraint is added to the model.
- pyaicad.table(variables, tuples)[source]¶
The variables take the values of one of the
tuples.Column
jof a tuple is the value of thej-th variable. Duplicate tuples are ignored, and a tuple with a value that is not in the domain of its variable is never used. With no tuple at all the constraint cannot be satisfied.>>> import pyaicad as ac >>> m = ac.Model() >>> x, y = m.int_vars(2, domain=range(3)) >>> m.add(ac.table([x, y], [(0, 1), (1, 2), (2, 0)])) >>> m.check([1, 2]), m.check([1, 1]) (True, False)
- pyaicad.disjunctive(variables, release, deadline, duration, precedences=None, setup_times=None, setup_relaxation='last_job', padding=False)[source]¶
The variables are a sequence of all the jobs, processed one at a time (a unary resource).
variables[k]is the job processed in positionk: its value is a job number0..n-1, wherenis the number of variables, so the values are a permutation of the jobs. Jobjhas release daterelease[j], deadlinedeadline[j](the latest time at which it may be completed) and durationduration[j]. Each job starts as soon as the machine is free and the job is released, and runs without interruption.precedencesis an optional list of pairs(i, j)of job numbers: jobiis processed before jobj(not necessarily right before). The precedences must not form a cycle.setup_timesis an optionalnbynmatrix:setup_times[i][j]is the time that has to pass between the end of jobiand the start of jobjwhenjfollowsi. The first job needs no setup, the diagonal is ignored, and no entry may be negative.setup_relaxationsays what a node of a relaxed diagram remembers about the job that the next setup depends on, and only matters withsetup_times. It does not change the solutions, only how many nodes the compilation needs and how well a relaxed diagram prunes."last_job"(the default) keeps one job number per node, the cheapest."last_set"keeps the set of these jobs, which gives tighter bounds when nodes are merged."arc_times"keeps one time per job, the tightest and the most expensive (O(n)numbers per node and per edge).With
padding=Truethe valuen(one more than the last job number) is a dummy job that fills the end of the sequence, and the number of variables is free: the sequence has the jobs that the machine processes, each at most once and in order, followed by dummies. Dummies take no time and no setup, and cannot be followed by a job. The domains must containn. Not every job has to appear (another constraint decides on which machine each one runs), a precedence only binds the jobs that appear, and the lists still have one entry per job.>>> import pyaicad as ac >>> m = ac.Model() >>> x = m.int_vars(3, domain=range(3)) >>> # Job 1 has to be over by time 4: it cannot come after job 0. >>> m.add(ac.disjunctive(x, release=[0, 0, 0], deadline=[10, 4, 10], duration=[3, 2, 2])) >>> m.check([1, 0, 2]), m.check([0, 1, 2]) (True, False)
>>> m = ac.Model() >>> x = m.int_vars(3, domain=range(3)) >>> m.add(ac.disjunctive(x, [0, 0, 0], [10, 4, 10], [3, 2, 2], precedences=[(2, 1)])) >>> m.check([2, 1, 0]), m.check([1, 0, 2]) (True, False)
>>> # Two slots for three jobs: the machine runs two of them, or only one and a dummy (3). >>> m = ac.Model() >>> x = m.int_vars(2, domain=range(4)) >>> m.add(ac.disjunctive(x, [0, 0, 0], [5, 5, 5], [2, 2, 2], padding=True)) >>> m.check([0, 2]), m.check([1, 3]), m.check([3, 3]), m.check([3, 1]), m.check([0, 0]) (True, True, True, False, False)
Compiling¶
- class pyaicad.Compiler(model, *, order='auto', merge='state_similarity', constraints=None)[source]¶
Compiles a model into decision diagrams.
The compiler is made for a model and the heuristics that drive the compilation; it then hands out diagrams, as exact or as relaxed as asked:
compile(). It works on the model as it is when the compiler is created. Each diagram is independent of the others and can be refined further (MDD.refine()) until it is frozen (MDD.freeze()).>>> import pyaicad as ac >>> m = ac.Model() >>> x = m.int_vars(3, domain=range(3)) >>> m.add(ac.all_different(x)) >>> mdd = ac.Compiler(m).compile() >>> mdd.count() 6
- Parameters:
model (Model) – The model to compile.
order (Union[str, Sequence[Union[Var, int]]]) –
"auto"to let the compiler choose the order of the layers, or a sequence listing the variables from the first layer to the last.merge (str) – How the nodes of a layer that is too wide are merged:
"state_similarity"(the default),"less_relaxed"or"most_likely". Only used by relaxed diagrams.constraints (Optional[Sequence[int]]) – Compile only these constraints, given as positions in
model.constraints. By default all of them. Only the variables in their scope get a layer.
- compile(width=None, max_iterations=None)[source]¶
A new diagram of the model.
Without
widththe diagram is exact: its paths are exactly the solutions of the model. An exact diagram can grow without bound and fill the memory, so give awidthfor models whose size you do not know.With
width, the diagram is relaxed: no layer has more thanwidthnodes, and every solution of the model is still a path, but some paths are not solutions.max_iterationsis the most passes that the refinement makes (a pass visits every layer once); by default it goes on until nothing more can be split. The later passes tighten a diagram little for what they cost, so a limit trades a looser diagram, still a valid relaxation, for time. At least 1.
- class pyaicad.MDD(model, native, width)[source]¶
A compiled diagram. Returned by
Compiler.compile().Each layer branches on one variable; a path from the root to the sink assigns every variable in the diagram. In an exact diagram the paths are the solutions, in a relaxed one they are a superset of them: use
Model.check()to know whether a path is a solution.- property is_unsat: bool¶
Whether the model is proved to have no solution. A relaxed diagram can prove it too.
- refine(width=None, max_iterations=None)[source]¶
Tightens the diagram in place, up to
widthnodes per layer (None: exact).A diagram compiled with a small width can be refined step by step, each step keeping the solutions and removing paths that are not. Refining to a width below the current one merges nodes again, giving a looser diagram. Fails on a frozen diagram.
max_iterationslimits the passes of this refinement, as inCompiler.compile(), and is chosen at each call: many passes to a small width, then few to a large one.
- freeze()[source]¶
Drops what only refining needs and keeps the diagram. Returns the diagram itself.
A diagram that can still be refined keeps its compilation alive: the constraints, their properties and the heuristics, which is often most of the memory. Freeze it once it is tight enough. Everything but
refine()keeps working, and freezing twice does nothing.- Return type:
- count()[source]¶
The number of paths. For an exact diagram, the number of solutions of the model.
For a relaxed one it is an upper bound on that number. 0 when the model is unsatisfiable.
- Return type:
- property scope: List[Var]¶
The variables the diagram branches on, in the order they were declared.
All the variables of the model unless some are in no compiled constraint: they have no layer, and
solution()andsample()give them the first value of their domain.
- solution()[source]¶
A solution read off the diagram, as one value per variable of the model, or
None.The solution is a path of exact nodes, so it satisfies the compiled constraints. An exact diagram has one whenever the model is satisfiable. A relaxed diagram may hold solutions that this does not find:
Noneproves nothing unlessis_unsat.
- sample(n=1)[source]¶
npaths drawn at random, as one value per variable of the model.In an exact diagram every solution is equally likely to be drawn. A path of a relaxed diagram is not necessarily a solution: check it with
Model.check(). Callpyaicad.set_seed()first to make them reproducible. Empty if the model is unsatisfiable.
Local search¶
- pyaicad.local_search(problems: Model, search: NeuralPriorSearch | NeuralPriorBPSearch | BeliefPropagationSearch, limits: Limits | None = None, *, seed: int | None = None) Result[source]¶
- pyaicad.local_search(problems: Sequence[Model], search: NeuralPriorSearch | NeuralPriorBPSearch | BeliefPropagationSearch, limits: Limits | None = None, *, seed: int | None = None) List[Result]
Runs a local search on a model, or on a list of models, and returns a
Resultfor each.- Parameters:
problems (Model | Sequence[Model]) – A model, giving one result, or a list of models, giving a list of results in the same order.
search (NeuralPriorSearch | NeuralPriorBPSearch | BeliefPropagationSearch) – How the search repairs:
NeuralPriorSearch,NeuralPriorBPSearchorBeliefPropagationSearch, with their settings.limits (Limits | None) – When to stop, per problem. No limit by default: a search that finds no solution then runs forever.
seed (int | None) – Makes the run reproducible: it seeds the search and every other source of randomness (as
pyaicad.set_seed()does). Unset, the run follows the current state of those.
- Return type:
- class pyaicad.BeliefPropagationSearch(destroy='random', destroy_fraction=1.0, stochastic=True, bp_iterations=1, batch_size=None)[source]¶
Solves by local search that repairs with belief propagation on the MDDs of the constraints, starting from uniform probabilities. It needs no network and runs on the CPU only, and the problems of a batch may have different sizes.
- Parameters:
destroy (str) – Which variables are repaired at each iteration; see
NeuralPriorSearch.destroy_fraction (float) – The fraction of the variables repaired at each iteration.
stochastic (bool) – Sample the values from the marginals instead of taking the most likely ones. Uniform probabilities tie everywhere, so this is what lets the search move.
bp_iterations (int) – Rounds of belief propagation per iteration.
batch_size (int | None) – How many problems are stepped together; see
NeuralPriorSearch.
- class pyaicad.NeuralPriorSearch(checkpoint, destroy='random', destroy_fraction=1.0, stochastic=False, temperature=1.0, batch_size=None)[source]¶
Solves by local search guided by a trained network: at each iteration, part of the current assignment is destroyed and repaired from the network’s predictions (its prior over the values).
What problems a network accepts depends on the network: see its documentation in the Rust crate (
neural::consformerfor ConsFormer).- Parameters:
checkpoint (Checkpoint | str | PathLike[str]) – The trained network, a
Checkpointor the path of one.destroy (str) – Which variables are repaired at each iteration:
"random"ones, the"worst"ones (those in the most violated constraints) or"related"ones (sharing constraints with a first one).destroy_fraction (float) – The fraction of the variables repaired at each iteration.
stochastic (bool) – Sample the values from the network’s prediction instead of taking the most likely ones.
temperature (float) – Softens (above 1) or sharpens (below 1) the prediction when
stochastic.batch_size (int | None) – How many problems are stepped together on the device;
Noneputs them all in one batch. Batches run one after the other, each with the full limits. Use 1 to solve problems one at a time, as a deployment would.
- class pyaicad.NeuralPriorBPSearch(checkpoint, destroy='related', destroy_fraction=1.0, stochastic=False, bp_iterations=1, batch_size=None)[source]¶
Solves by local search guided by a trained network whose predictions are the prior of belief propagation on the MDDs of the constraints, which chooses the values.
What problems a network accepts depends on the network: see its documentation in the Rust crate (
neural::consformerfor ConsFormer).- Parameters:
checkpoint (Checkpoint | str | PathLike[str]) – The trained network, a
Checkpointor the path of one.destroy (str) – Which variables are repaired at each iteration; see
NeuralPriorSearch."related"by default, which suits the refinement.destroy_fraction (float) – The fraction of the variables repaired at each iteration.
stochastic (bool) – Sample the values from the refined marginals instead of taking the most likely ones.
bp_iterations (int) – Rounds of belief propagation per iteration.
batch_size (int | None) – How many problems are stepped together on the device; see
NeuralPriorSearch.
- class pyaicad.Limits(time=None, iterations=None)[source]¶
When to stop. Whichever limit is reached first stops the search.
The limits apply to each problem separately:
Limits(time=10)gives every problem of a list up to 10 seconds.
Settings and errors¶
- pyaicad.set_seed(seed)[source]¶
Seeds every source of randomness of the library, so that a run can be reproduced.
This covers weight initialisation, sampling from a diagram or a network, the choices of the search, and the shuffling done during training.
- Parameters:
seed (int)
- Return type:
None
- pyaicad.set_num_threads(n)[source]¶
Sets how many threads the library may use for its parallel work: solving a batch of problems, training, and building the datasets for it.
Unless this is called, the library uses a quarter of the threads available on the machine (at least one), so that it does not take over a shared server. Raise it to use more of the machine. It can be called at any time, even between two uses of the library; work already running finishes with the threads it had.
Compiling a single diagram always uses one thread. The number of threads is unrelated to
batch_sizeand to what runs on a GPU.- Raises:
TypeError –
nis not an integer.ValueError –
nis less than 1.
- Parameters:
n (int)
- Return type:
None
- pyaicad.get_num_threads()[source]¶
The number of threads the library uses for its parallel work: the value given to
set_num_threads(), or the default (a quarter of the available threads, at least one).- Return type:
- pyaicad.set_log_level(level)[source]¶
Sets how much the library logs:
"off"(the default),"error","warning","info","debug"or"trace".The library logs through the standard
loggingmodule, under the logger"aicad". If your program has not configured logging, a handler writing to standard error is added to that logger so the messages are visible.- Parameters:
level (str)
- Return type:
None
- pyaicad.version()[source]¶
Returns the build of the library that is running: its version, the commit it was built from, the Rust compiler and the build settings.
>>> import pyaicad as ac >>> ac.version().profile in ("debug", "release") True
Benchmarks are only comparable between commits, so run them from a clean copy of a commit and keep this with the results. The same record is the first line of every file written by
pyaicad.diagnostics.enable_data_log().- Return type:
- class pyaicad.BuildInfo(version, commit, rustc, target, profile, opt_level, features)[source]¶
The build of the library that is running: what was compiled into the native extension.
The version of the source tree says little about the code that runs, which may be an installed copy of another commit. Record this next to any measurement.
- Parameters:
- pyaicad.HAS_LEARNING = True¶
bool(x) -> bool
Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.
- exception pyaicad.ModelError[source]¶
The model, or one of its variables or constraints, is invalid.
- exception pyaicad.CheckpointError[source]¶
A checkpoint is missing, incomplete, or cannot be used for the requested problems.
The feature needs a part of pyaicad that this build does not include.
Training and the neural searches come with the
learningfeature of the native library.
Training¶
These need the full build.
Training the networks that guide the search.
A training set is a list of problems: one problem per training example. Dataset splits a
list into training and validation sets; fit() trains a network on it with a named
recipe. The problems you evaluate on are kept apart by you and never given to fit(); the trained network is a Checkpoint that the neural searches (pyaicad.NeuralPriorSearch,
pyaicad.NeuralPriorBPSearch) solve with.
Each network has its own restrictions on the problems it can be trained on and used with; they are
documented with the network in the Rust crate (neural::consformer for ConsFormer), not here.
>>> import pyaicad as ac
>>> from pyaicad import learning
>>> ckpt = learning.fit(train_problems, "consformer-mdd", checkpoint_dir="ckpt", epochs=50)
>>> results = ac.local_search(test_problems, ac.NeuralPriorBPSearch(ckpt))
- class pyaicad.learning.Dataset(train, validation)[source]¶
The problems a network is trained on: training and validation problems.
The validation set is used during training to keep the best network. There is no test set on purpose: evaluating on problems that training could have seen proves nothing, so the problems you evaluate on are yours to keep apart and never pass to
fit().- classmethod split(problems, validation_fraction=0.2, *, seed=None)[source]¶
Splits
problemsat random into training and validation sets.validation_fractionis the share of the problems kept for validation, strictly between 0 and 1; both sets get at least one problem. The sameseedgives the same split.
- class pyaicad.learning.Network(domain_size='auto', embedding_size=128, hidden_size=128, num_heads=1, expand_size=128, num_layers=1, dropout=0.0, bias=True, positional_encoding_dimensions=0, mask_fraction=0.5, tau=0.1, learned_attention_mask=False)[source]¶
The architecture of a ConsFormer network.
domain_sizeis the number of values the network can predict: values0todomain_size - 1."auto"takes the smallest size covering the problems it is trained on, which requires non-negative values.
- class pyaicad.learning.Adam(lr=0.0003, beta_1=0.9, beta_2=0.999, epsilon=1e-05, amsgrad=False, weight_decay=None, grad_clip_norm=None, grad_clip_value=None)[source]¶
The Adam optimiser.
weight_decayis an L2 penalty (Nonefor none).grad_clip_normclips the L2 norm of each gradient tensor andgrad_clip_valueclips each element of the gradient; set at most one.
- class pyaicad.learning.AdamW(lr=0.0003, beta_1=0.9, beta_2=0.999, epsilon=1e-05, amsgrad=False, weight_decay=0.0001, grad_clip_norm=None, grad_clip_value=None)[source]¶
Adam with a decoupled weight decay, which is always applied (
0for none).grad_clip_normclips the L2 norm of each gradient tensor andgrad_clip_valueclips each element of the gradient; set at most one.
- class pyaicad.learning.SGD(lr=0.01, momentum=None, dampening=0.0, nesterov=False, weight_decay=None, grad_clip_norm=None, grad_clip_value=None)[source]¶
Stochastic gradient descent, with momentum if
momentumis set.dampeningandnesterovonly apply with a momentum.weight_decayis an L2 penalty (Nonefor none).grad_clip_normclips the L2 norm of each gradient tensor andgrad_clip_valueclips each element of the gradient; set at most one.
- pyaicad.learning.Optimiser¶
-
- Type:
An optimiser with its settings
- class pyaicad.learning.Training(optimiser=<factory>, epochs=10, batch_size=32, validation_interval=10, early_stopping_patience=None, early_stopping_min_delta=0.0001, initial_weights=None, destroy='random')[source]¶
How the network is optimised.
optimiseris the optimiser with its learning rate and settings (Adam by default). The network is evaluated on the validation set everyvalidation_intervalepochs, and the best one so far is kept; sovalidation_intervalmust not exceedepochs.initial_weightsis the checkpoint directory of an earlier run: its weights initialise the network before the first epoch, to continue or fine-tune that run. The network settings must be the ones the weights were trained with. By default the network starts from scratch.
- class pyaicad.learning.Recipe(name, loss, network=<factory>, training=<factory>, order='auto', merge='state_similarity', bp_rounds=0, gumbel_scale=1.0)[source]¶
A way of training a network: the loss, the architecture and the optimiser settings.
Use one of the named recipes in
RECIPES, optionally with changes:>>> Recipe.named("consformer-mdd").replace(epochs=50, lr=1e-3).training.epochs 50 >>> Recipe.named("consformer").replace(optimiser=SGD(momentum=0.9)).training.optimiser.lr 0.01
replacetakes the name of any setting of the network, the training, or the recipe itself, and refuses names it does not know.With the
"mdd"loss,bp_roundsis the number of rounds of belief propagation (the one ofpyaicad.NeuralPriorBPSearch) that label the diagram of each constraint before its weighted model count is taken: the network’s probabilities are the prior of each variable, and the diagram of a constraint is labelled with that prior tilted by what the other constraints say about the variable. The loss then sees the other constraints, and scores the weights that the search labels its diagrams with.0, the default, labels the diagrams with the network’s probabilities as they are; the gradient is taken with respect to them, the messages of belief propagation being constants. The setting has no effect on the"classical"loss.gumbel_scalemultiplies the Gumbel noise that is added to the network’s logits before their softmax turns them into the probabilities the"mdd"loss scores.1.0, the default, is the Gumbel-softmax relaxation of ConsFormer;0.0adds no noise, so the loss is the exact expectation under the plain softmax of the logits, and is deterministic (so is the validation loss that selects the best network). It applies to the whole loss, belief propagation included, and has no effect on the"classical"loss.>>> Recipe.named("consformer-mdd").bp_rounds 0 >>> Recipe.named("consformer-mdd").replace(bp_rounds=1).bp_rounds 1 >>> Recipe.named("consformer-mdd").replace(bp_rounds=5).bp_rounds 5 >>> Recipe.named("consformer-mdd").gumbel_scale 1.0 >>> Recipe.named("consformer-mdd").replace(gumbel_scale=0.0).gumbel_scale 0.0
- Parameters:
- pyaicad.learning.RECIPES: Dict[str, Recipe] = {'consformer': Recipe(name='consformer', loss='classical', network=Network(domain_size='auto', embedding_size=128, hidden_size=128, num_heads=1, expand_size=128, num_layers=1, dropout=0.0, bias=True, positional_encoding_dimensions=0, mask_fraction=0.5, tau=0.1, learned_attention_mask=False), training=Training(optimiser=Adam(lr=0.0003, beta_1=0.9, beta_2=0.999, epsilon=1e-05, amsgrad=False, weight_decay=None, grad_clip_norm=None, grad_clip_value=None), epochs=10, batch_size=32, validation_interval=10, early_stopping_patience=None, early_stopping_min_delta=0.0001, initial_weights=None, destroy='random'), order='auto', merge='state_similarity', bp_rounds=0, gumbel_scale=1.0), 'consformer-mdd': Recipe(name='consformer-mdd', loss='mdd', network=Network(domain_size='auto', embedding_size=128, hidden_size=128, num_heads=1, expand_size=128, num_layers=1, dropout=0.0, bias=True, positional_encoding_dimensions=0, mask_fraction=0.5, tau=0.1, learned_attention_mask=False), training=Training(optimiser=Adam(lr=0.0003, beta_1=0.9, beta_2=0.999, epsilon=1e-05, amsgrad=False, weight_decay=None, grad_clip_norm=None, grad_clip_value=None), epochs=10, batch_size=32, validation_interval=10, early_stopping_patience=None, early_stopping_min_delta=0.0001, initial_weights=None, destroy='random'), order='auto', merge='state_similarity', bp_rounds=0, gumbel_scale=1.0)}¶
The named recipes.
"consformer"trains with a hand-written penalty per constraint type;"consformer-mdd"trains against the exact weighted model count of each constraint’s MDD.
- pyaicad.learning.fit(data, recipe='consformer-mdd', *, checkpoint_dir, seed=None, **settings)[source]¶
Trains a network and keeps the best one found in
checkpoint_dir.The network with the lowest loss on the validation set is written to
checkpoint_dirduring training, so an interrupted run still leaves a usable one.- Parameters:
data (Dataset | Sequence[Model]) – A
Dataset, or a list of problems, which is split 80/20 into training and validation sets (useDataset.split()for another share). Never include the problems you evaluate on.recipe (str | Recipe) – The name of a recipe in
RECIPES, or aRecipe.checkpoint_dir (str | PathLike[str]) – Where the network is written. Created if missing.
seed (int | None) – Seeds the library’s randomness (see
pyaicad.set_seed()) before training, and the split of a plain list.**settings (Any) – Changes to the recipe, by name, as in
Recipe.replace():fit(data, "consformer", checkpoint_dir="ckpt", epochs=50, embedding_size=64).
- Returns:
The
Checkpointholding the best network.- Return type:
- pyaicad.learning.load(path)[source]¶
Opens a checkpoint written by
fit(). SeeCheckpoint.load().- Parameters:
- Return type: