neuralogic.core packageο
Subpackagesο
- neuralogic.core.builder package
- Submodules
- neuralogic.core.builder.builder module
- neuralogic.core.builder.components module
- neuralogic.core.builder.dataset module
- neuralogic.core.builder.dataset_builder module
- Module contents
- neuralogic.core.constructs package
- Subpackages
- neuralogic.core.constructs.function package
- Submodules
- neuralogic.core.constructs.function.concat module
- neuralogic.core.constructs.function.enum module
- neuralogic.core.constructs.function.function module
- neuralogic.core.constructs.function.function_container module
- neuralogic.core.constructs.function.function_graph module
- neuralogic.core.constructs.function.reshape module
- neuralogic.core.constructs.function.slice module
- neuralogic.core.constructs.function.softmax module
- Module contents
- neuralogic.core.constructs.function package
- Submodules
- neuralogic.core.constructs.factories module
AtomFactoryConstantFactoryHiddenPredicateFactorySpecialPredicateFactorySpecialPredicateFactory.add()SpecialPredicateFactory.add_eval()SpecialPredicateFactory.alldiff()SpecialPredicateFactory.anypred()SpecialPredicateFactory.div_eval()SpecialPredicateFactory.eq()SpecialPredicateFactory.geq()SpecialPredicateFactory.get()SpecialPredicateFactory.gt()SpecialPredicateFactory.hiddenSpecialPredicateFactory.leq()SpecialPredicateFactory.lt()SpecialPredicateFactory.max_eval()SpecialPredicateFactory.maxcard()SpecialPredicateFactory.min_eval()SpecialPredicateFactory.mod()SpecialPredicateFactory.mod_eval()SpecialPredicateFactory.mul_eval()SpecialPredicateFactory.neq()SpecialPredicateFactory.next()SpecialPredicateFactory.sub()SpecialPredicateFactory.sub_eval()SpecialPredicateFactory.truepred()
VariableFactory
- neuralogic.core.constructs.java_objects module
JavaFactoryJavaFactory.add_metadata_function()JavaFactory.add_parametrized_function()JavaFactory.atom_to_clause()JavaFactory.get_conjunction()JavaFactory.get_generic_relation()JavaFactory.get_lifted_example()JavaFactory.get_metadata()JavaFactory.get_new_weight_factory()JavaFactory.get_predicate()JavaFactory.get_predicate_metadata_pair()JavaFactory.get_query()JavaFactory.get_relation()JavaFactory.get_rule()JavaFactory.get_term()JavaFactory.get_valued_fact()JavaFactory.get_variable_factory()JavaFactory.get_weight()JavaFactory.to_clause()
ValueFactory
- neuralogic.core.constructs.metadata module
- neuralogic.core.constructs.predicate module
- neuralogic.core.constructs.relation module
- neuralogic.core.constructs.rule module
- neuralogic.core.constructs.term module
- Module contents
- Subpackages
- neuralogic.core.settings package
- Submodules
- neuralogic.core.settings.settings_proxy module
SettingsProxySettingsProxy.chain_pruningSettingsProxy.clip_grad_normSettingsProxy.clip_grad_valueSettingsProxy.debug_exportingSettingsProxy.default_fact_valueSettingsProxy.error_functionSettingsProxy.get_aggregation_function()SettingsProxy.get_combination_function()SettingsProxy.get_transformation_function()SettingsProxy.grounderSettingsProxy.initializerSettingsProxy.initializer_constSettingsProxy.initializer_uniform_scaleSettingsProxy.iso_value_compressionSettingsProxy.optimizerSettingsProxy.prune_only_identitiesSettingsProxy.relation_combinationSettingsProxy.relation_transformationSettingsProxy.rule_aggregationSettingsProxy.rule_combinationSettingsProxy.rule_transformationSettingsProxy.to_json()
- Module contents
- neuralogic.core.torch package
Submodulesο
neuralogic.core.enums moduleο
neuralogic.core.model moduleο
- class Model(*, model_file: str | None = None)[source]ο
Bases:
NeuralModuleModel is a collection of rules and relations that define the structure of the neural model.
- add_module(module: Module) None[source]ο
Expands the module into rules and adds them into the model.
- Parameters:
module (Module) β The module to expand and add.
- add_rule(rule: BaseRelation | WeightedRelation | Rule | PredicateMetadata) None[source]ο
Adds one rule to the model.
- Parameters:
rule (ModelEntries) β The rule to add.
- add_rules(rules: list[BaseRelation | WeightedRelation | Rule | PredicateMetadata]) None[source]ο
Adds multiple rules to the model.
- Parameters:
rules (list[ModelEntries]) β The rules to add.
- build(settings: Settings | None = None, torch: bool = False) Model[source]ο
Builds the model into a neural model.
- derivable_queries(example: list[BaseRelation | Rule] | None = None) list[BaseRelation] | dict[source]ο
Returns all derivable queries for the provided example.
- Parameters:
example (list[BaseRelation | Rule], optional) β The example to derive queries from. Default: None.
- Returns:
The list of derivable queries.
- Return type:
list[BaseRelation] | dict
- load(path: str | Path) None[source]ο
Load model weights from a file saved by
save().The model must already be built with the same architecture that produced the saved file.
- Parameters:
path (str | Path) β Path to the saved file.
- q(query: BaseRelation, examples: list[BaseRelation | Rule] | None = None) list[dict] | dict[source]ο
- query(query: BaseRelation, examples: list[BaseRelation | Rule] | None = None) list[dict] | dict[source]ο
Performs a query on the model with the provided examples.
- Parameters:
query (BaseRelation) β The query to perform.
examples (list[BaseRelation | Rule], optional) β The examples to use for the query. Default: None.
- Returns:
The list of query results (substitutions).
- Return type:
list[dict] | dict
neuralogic.core.neural_module moduleο
- class NeuralModule[source]ο
Bases:
objectNeuralModule is the base class for all neural models. It provides methods for grounding, building, training, and testing.
- build_dataset(dataset: BaseDataset | GroundedDataset, *, batch_size: int = 1, learnable_facts: bool = False, progress: bool = False) BuiltDataset[source]ο
Builds (ground and neuralize) the provided dataset.
- Parameters:
dataset (Union[BaseDataset, GroundedDataset]) β The dataset to build.
batch_size (int) β The batch size. Default: 1.
learnable_facts (bool) β Whether facts are learnable. Default: False.
progress (bool) β Whether to show progress. Default: False.
- Returns:
The built dataset.
- Return type:
- build_static_dataset(dataset: Dataset, *, batch_size: int = 1, learnable_facts: bool = False, progress: bool = False) StaticGraphDataset[source]ο
Build a static-graph dataset from a logic
Dataset.Only the first sample is grounded and neuralized. The resulting
StaticGraphDatasetreuses the same neural graph for every sample, updating fact values viaset_fact_valuebefore each learning step.- Parameters:
dataset (Dataset) β The dataset with one or more samples sharing identical structure.
batch_size (int) β The batch size. Default: 1.
learnable_facts (bool) β Whether facts are learnable. Default: False.
progress (bool) β Whether to show progress. Default: False.
- Return type:
- draw(filename: str | None = None, show=True, img_type='png', value_detail: int = 0, graphviz_path: str | None = None, settings: DrawingSettings | None = None, *args, **kwargs)[source]ο
- fixed_state_dict() dict[source]ο
Returns the weights training does not touch, in the same shape as
state_dict().A fixed weight is a modelling choice rather than a parameter - an initial hidden state, say - so it is deliberately absent from
state_dict(), which describes what training changes. Reading one is still a reasonable thing to want, and without this the only way was through the private Java model.The libraryβs own internal constants sit at negative indices, the logical ONE among them. Those are not modelling choices and are left out.
- Returns:
The fixed weights and their names.
- Return type:
dict
- ground(dataset: BaseDataset, *, batch_size: int = 1, learnable_facts: bool = False, progress: bool = False) GroundedDataset[source]ο
Grounds the provided dataset using the modelβs settings.
- Parameters:
dataset (BaseDataset) β The dataset to ground.
batch_size (int) β The batch size for grounding. Default: 1.
learnable_facts (bool) β Whether facts are learnable. Default: False.
progress (bool) β Whether to show progress. Default: False.
- Returns:
The grounded dataset.
- Return type:
- load_fixed_state_dict(state_dict: dict)[source]ο
Sets the weights training does not touch, from a
fixed_state_dict()shaped dictionary.Setting one is initialization, not learning, so this is separate from
load_state_dict()- which skips fixed weights precisely because training must not move them.- Parameters:
state_dict (dict) β Fixed weights to set, keyed by weight index. Indices absent from the model are an error, and a learnable index is refused rather than quietly written.
- loss(dataset) float[source]ο
The datasetβs loss, reduced the way the error function says.
This is the single number torchβs criterion hands back, and the quantity the optimizer is descending: the per-query errors summed and then divided by the batchβs total element count under
reduction="mean", or left undivided under"sum".It is deliberately separate from
validate(), whose per-query values are not reduced across the batch - each is summed over its own components, which is torchβsreduction="none". Both are useful, and conflating them is what let a reported number drift away from the one being minimised once before.- Parameters:
dataset (Any) β The dataset to take the loss of.
- Returns:
The reduced loss.
- Return type:
float
- parameters() dict[source]ο
Returns the model parameters.
- Returns:
The model parameters.
- Return type:
dict
- state_dict() dict[source]ο
Returns the state dictionary of the model.
- Returns:
The state dictionary (weights and weight names).
- Return type:
dict
- test(dataset) list | float[source]ο
Tests the model on the provided dataset.
- Parameters:
dataset (Any) β The dataset to test on.
- Returns:
The test results (outputs).
- Return type:
Union[Value, List[Value]]
- train(dataset, epochs: int = 1) list | float[source]ο
Trains the model on the provided dataset.
- Parameters:
dataset (Any) β The dataset to train on. Can be a Dataset, GroundedDataset, BuiltDataset, StaticGraphDataset, or a list of samples.
epochs (int) β The number of epochs to train. Default: 1.
- Returns:
The training results (target, output, error).
- Return type:
Union[Tuple[Value, Value, Value], List[Tuple[Value, Value, Value]]]
- train_with_metrics(dataset, epochs: int = 1, metrics=None)[source]ο
Trains like
train()and also computes Java deep metrics.- Parameters:
dataset (Any) β Same inputs as
train().epochs (int) β Number of epochs. Default: 1.
metrics (Sequence[str] or None) β Java metric names to compute (
auc_roc,auc_pr,best_accuracy,best_threshold,saturation).
- Returns:
(results, java_metrics)whereresultshas the same shape astrain()andjava_metricsis adict[str, float].- Return type:
tuple
- validate(dataset) list | float[source]ο
Evaluates the model on the provided dataset and reports the error, without training on it.
Same shape of result as
train(), so a validation loss can be computed the same way, but nothing is backpropagated and the optimizer is not stepped.- Parameters:
dataset (Any) β The dataset to validate on.
- Returns:
The validation results (target, output, error).
- Return type:
Union[Tuple[Value, Value, Value], List[Tuple[Value, Value, Value]]]
- validate_with_metrics(dataset, metrics=None)[source]ο
Evaluates like
validate()and also computes Java deep metrics.- Parameters:
dataset (Any) β Same inputs as
validate().metrics (Sequence[str] or None) β Java metric names to compute (
auc_roc,auc_pr,best_accuracy,best_threshold,saturation).
- Returns:
(results, java_metrics)whereresultshas the same shape asvalidate()andjava_metricsis adict[str, float].- Return type:
tuple
- vectorize(dataset: BaseDataset)[source]ο
Builds a PyTorch vectorized network from the provided dataset.
- Parameters:
dataset (BaseDataset) β The dataset to build and vectorize.
- Returns:
The vectorized PyTorch model.
- Return type:
torch.nn.Module
neuralogic.core.sources moduleο
- class Sources(sources: Any)[source]ο
Bases:
objectRepresents the logic sources (models, examples, queries) for the NeuraLogic backend.
- static from_args(args: list[str], settings: SettingsProxy) Sources[source]ο
Creates Sources from command line arguments and settings.
- Parameters:
args (List[str]) β The command line arguments.
settings (SettingsProxy) β The settings proxy.
- Returns:
The created Sources object.
- Return type:
- static from_settings(settings: SettingsProxy) Sources[source]ο
Creates Sources from the provided settings.
- Parameters:
settings (SettingsProxy) β The settings proxy.
- Returns:
The created Sources object.
- Return type:
Module contentsο
- class Aggregation[source]ο
Bases:
objectCollection of aggregation functions. Aggregation functions are used to aggregate multiple inputs, typically from different groundings of the same rule.
- AVG: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- CONCAT: ConcatAggregation = <neuralogic.core.constructs.function.concat.ConcatAggregation object>ο
- COUNT: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- MAX: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- MIN: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- SOFTMAX: SoftmaxAggregation = <neuralogic.core.constructs.function.softmax.SoftmaxAggregation object>ο
- SUM: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- class BuiltDataset(samples: list[NeuralSample], batch_size: int)[source]ο
Bases:
objectBuiltDataset represents an already built dataset - that is, a dataset that has been grounded and neuralized.
- load_state_dict(state_dict: dict, strict: bool = True) IncompatibleKeys[source]ο
Sets this datasetβs example-fact parameters from a
state_dict()shaped dictionary.With
strict=Falsethis is also how a parameter reaches a dataset it was not trained on - the embeddings learned for the training set, carried onto the test set for the constants the two share:test_data.load_state_dict(train_data.state_dict(), strict=False)
A constant the training set never saw keeps whatever its example wrote, untrained, and comes back in
missing_keys; a trained parameter with no fact to attach to here comes back inunexpected_keys. Both are ordinary in that use and neither is in the round trip of one dataset, which is whystrictdefaults to refusing them.- Parameters:
state_dict (dict) β
{"weights": {literal: value}}.strict (bool) β Whether the literals must match this datasetβs exactly, as in torch. Default: True.
- Returns:
missing_keys- this datasetβs learnable facts the dictionary said nothing about - andunexpected_keys- literals in the dictionary this dataset has no learnable fact for.- Return type:
- Raises:
ValueError β Under
strict, if either list is non-empty: the saved parameters and the data have drifted apart, and carrying on would leave a model half restored. Always, if two literals that share one weight are given different values - facts share a weight when the example named it, and then only one of the two values could survive, which one being an accident of iteration order.
- state_dict() dict[source]ο
The learnable values this datasetβs own example facts carry, keyed by ground literal.
A value written on an example fact and made learnable with
learnable_facts=Trueis a real parameter - it trains - but it belongs to the data, not to the template, so it is not in the modelβsstate_dict()and saving the model does not save it. This is where it is.The key is the ground literal (
emb(a)) because nothing else survives a rebuild: the weightβs index continues a counter that keeps running, so building the same dataset twice on one model gives the parameters indices1, 2and then5, 6, and the generated weight name iswplus that index.- Returns:
{"weights": {literal: value}}, empty when the dataset was not built withlearnable_facts=True.- Return type:
dict
- class Combination[source]ο
Bases:
objectCollection of combination functions. Combination functions are used to combine multiple inputs into a single output, often as part of a rule body or for combining multiple rules.
- AVG: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- CONCAT: ConcatCombination = <neuralogic.core.constructs.function.concat.ConcatCombination object>ο
- COSSIM: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- COUNT: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- CROSSSUM: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- ELPRODUCT: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- MAX: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- MIN: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- PRODUCT: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- SOFTMAX: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- SPARSEMAX: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- SUM: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- class F[source]ο
Bases:
objectUtility class providing a flat namespace for common functions. It includes transformation, combination, and aggregation functions.
- avg: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- avg_agg: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- concat: ConcatCombination = <neuralogic.core.constructs.function.concat.ConcatCombination object>ο
- concat_agg: ConcatAggregation = <neuralogic.core.constructs.function.concat.ConcatAggregation object>ο
- cossim: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- count: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- count_agg: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- crossum: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- elproduct: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- exp: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- identity: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- inverse: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- leaky_relu: TransformationFunction = <neuralogic.core.constructs.function.leaky_relu.LeakyReLuTransformation object>ο
- log: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- lukasiewicz: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- max: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- max_agg: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- min: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- min_agg: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- norm: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- product: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- relu: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- reverse: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- sigmoid: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- signum: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- softmax: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- softmax_agg: SoftmaxAggregation = <neuralogic.core.constructs.function.softmax.SoftmaxAggregation object>ο
- softmax_comb: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- sparsemax: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- sparsemax_comb: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- sqrt: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- sum: CombinationFunction = <neuralogic.core.constructs.function.function.CombinationFunction object>ο
- sum_agg: AggregationFunction = <neuralogic.core.constructs.function.function.AggregationFunction object>ο
- tanh: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- transp: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- class GroundedDataset(groundings, builder: Builder)[source]ο
Bases:
objectGroundedDataset represents grounded examples that are not neuralized yet.
- neuralize(*, batch_size: int = 1, progress: bool = False) BuiltDataset[source]ο
- class Metadata(learnable: bool | None = None, transformation: TransformationFunction | CombinationFunction | None = None, combination: CombinationFunction | None = None, aggregation: AggregationFunction | None = None, duplicate_grounding: bool | None = None)[source]ο
Bases:
objectRepresents metadata for a logic construct (e.g., rule, predicate).
Metadata can specify properties like learnability, transformation functions, aggregation functions, and combination functions.
- aggregationο
- combinationο
- combine(other: Metadata) Metadata[source]ο
Combines this metadata with another Metadata object. Values from the other object take precedence.
- copy() Metadata[source]ο
Returns a shallow copy of the metadata.
- Returns:
The copy of the metadata.
- Return type:
- duplicate_groundingο
- static from_iterable(iterable: Iterable[Any]) Metadata[source]ο
Creates a Metadata object from an iterable of functions or values.
- Parameters:
iterable (Iterable) β The iterable containing metadata entries.
- Returns:
The created Metadata object.
- Return type:
- learnableο
- transformationο
- class Model(*, model_file: str | None = None)[source]ο
Bases:
NeuralModuleModel is a collection of rules and relations that define the structure of the neural model.
- add_module(module: Module) None[source]ο
Expands the module into rules and adds them into the model.
- Parameters:
module (Module) β The module to expand and add.
- add_rule(rule: BaseRelation | WeightedRelation | Rule | PredicateMetadata) None[source]ο
Adds one rule to the model.
- Parameters:
rule (ModelEntries) β The rule to add.
- add_rules(rules: list[BaseRelation | WeightedRelation | Rule | PredicateMetadata]) None[source]ο
Adds multiple rules to the model.
- Parameters:
rules (list[ModelEntries]) β The rules to add.
- build(settings: Settings | None = None, torch: bool = False) Model[source]ο
Builds the model into a neural model.
- derivable_queries(example: list[BaseRelation | Rule] | None = None) list[BaseRelation] | dict[source]ο
Returns all derivable queries for the provided example.
- Parameters:
example (list[BaseRelation | Rule], optional) β The example to derive queries from. Default: None.
- Returns:
The list of derivable queries.
- Return type:
list[BaseRelation] | dict
- load(path: str | Path) None[source]ο
Load model weights from a file saved by
save().The model must already be built with the same architecture that produced the saved file.
- Parameters:
path (str | Path) β Path to the saved file.
- q(query: BaseRelation, examples: list[BaseRelation | Rule] | None = None) list[dict] | dict[source]ο
- query(query: BaseRelation, examples: list[BaseRelation | Rule] | None = None) list[dict] | dict[source]ο
Performs a query on the model with the provided examples.
- Parameters:
query (BaseRelation) β The query to perform.
examples (list[BaseRelation | Rule], optional) β The examples to use for the query. Default: None.
- Returns:
The list of query results (substitutions).
- Return type:
list[dict] | dict
- class Rule(head: BaseRelation, body: RuleBody | Iterable[BodyItem] | BodyItem)[source]ο
Bases:
objectRepresents a rule in the model, consisting of a head and a body.
- body: list[BodyItem] | FContainerο
- headο
- class RuleBody(lit1: BaseRelation, lit2: BaseRelation)[source]ο
Bases:
objectRepresents the body of a rule, which is a collection of literals.
- literals: list['BaseRelation' | FContainer]ο
- class Settings(*, optimizer: Optimizer = <neuralogic.nn.optim.adam.Adam object>, error_function: ErrorFunction = <neuralogic.nn.loss.MSE object>, initializer: Initializer = <neuralogic.nn.init.Glorot object>, iso_value_compression: bool = True, chain_pruning: bool = True, prune_only_identities: bool = False, grounder: Grounder = Grounder.BUP, clip_grad_norm: float | None = None, clip_grad_value: float | None = None)[source]ο
Bases:
object- property chain_pruning: boolο
- property clip_grad_norm: float | Noneο
- property clip_grad_value: float | Noneο
- create_disconnected_proxy() SettingsProxy[source]ο
- create_proxy() SettingsProxy[source]ο
- property error_function: ErrorFunctionο
- property initializer: Initializerο
- property iso_value_compression: boolο
- property prune_only_identities: boolο
- class SettingsProxy(*, optimizer: Optimizer, error_function: ErrorFunction, initializer: Initializer, iso_value_compression: bool, chain_pruning: bool, prune_only_identities: bool, grounder: Grounder, clip_grad_norm: float | None = None, clip_grad_value: float | None = None)[source]ο
Bases:
objectProxy class for the Java Settings object.
It provides a Pythonic interface to configure various parameters of the NeuraLogic backend, such as optimizers, initializers, error functions, and grounding algorithms.
- property chain_pruning: boolο
Whether to use chain pruning (reducing redundant chains of operations).
- property clip_grad_norm: float | Noneο
The global gradient norm the whole gradient is rescaled down to before each step.
- property clip_grad_value: float | Noneο
The bound every gradient element is clamped to before each step.
- property debug_exporting: boolο
- property default_fact_value: floatο
- property error_function: Anyο
The error function used for training.
- get_aggregation_function(aggregation: Aggregation) Any[source]ο
- get_combination_function(combination: Combination) Any[source]ο
Returns the Java combination function for the given Python enum value.
- Parameters:
combination (Combination) β The combination function enum value.
- Returns:
The Java combination function object.
- Return type:
Any
- get_transformation_function(transformation: Transformation) Any[source]ο
- property grounder: Anyο
The grounding algorithm to use.
- property initializer: Anyο
The weight initializer used for model parameters.
- property initializer_const: floatο
- property initializer_uniform_scale: floatο
- property iso_value_compression: boolο
Whether to use iso-value compression.
- property prune_only_identities: boolο
- property relation_combination: CombinationFunctionο
- property relation_transformation: TransformationFunctionο
- property rule_aggregation: AggregationFunctionο
- property rule_combination: CombinationFunctionο
- property rule_transformation: TransformationFunctionο
- class Transformation[source]ο
Bases:
objectCollection of transformation functions. Transformation functions are applied element-wise or as join operations (e.g., Softmax, Transpose).
- EXP: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- IDENTITY: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- INVERSE: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- LEAKY_RELU: TransformationFunction = <neuralogic.core.constructs.function.leaky_relu.LeakyReLuTransformation object>ο
- LOG: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- LUKASIEWICZ: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- NORM: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- RELU: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- REVERSE: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- SIGMOID: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- SIGNUM: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- SOFTMAX: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- SPARSEMAX: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- SQRT: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- TANH: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο
- TRANSP: TransformationFunction = <neuralogic.core.constructs.function.function.TransformationFunction object>ο