Module: nsl.lib

Library APIs for Neural Structured Learning.

Classes

class GenNeighbor: Abstract class for generating neighbors.

Functions

adv_regularizer(...): Calculates adversarial loss from generated adversarial samples.

apply_feature_mask(...): Applies a feature mask on features if the feature_mask is not None.

decay_over_time(...): Returns a decayed value of init_value over time.

gen_adv_neighbor(...): Generates adversarial neighbors for the given input and loss.

get_target_indices(...): Selects targeting classes for adversarial attack (classification only).

jensen_shannon_divergence(...): Adds a Jensen-Shannon divergence to the training procedure.

kl_divergence(...): Adds a KL-divergence to the training procedure.

maximize_within_unit_norm(...): Solves the maximization problem weights^T*x with the constraint norm(x)=1.

normalize(...): Normalizes the values in tensor with respect to a specified vector norm.

pairwise_distance_wrapper(...): A wrapper to compute the pairwise distance between sources and targets.

project_to_ball(...): Projects batched tensors to a ball with the given radius in the given norm.

random_in_norm_ball(...): Generates a random sample in a norm ball, conforming the given structure.

replicate_embeddings(...): Replicates the given embeddings by replicate_times.

strip_neighbor_features(...): Strips graph neighbor features from a feature dictionary.

unpack_neighbor_features(...): Extracts sample features, neighbor features, and neighbor weights.

virtual_adv_regularizer(...): Calculates virtual adversarial loss for the given input.