alpine.vis.geometry package#

Submodules#

alpine.vis.geometry.local_complexity module#

Code is adapted from Deep Networks Always Grok and Here is Why, Humayun et.al., ICML 2024 AhmedImtiazPrio/grok-adversarial

alpine.vis.geometry.local_complexity.flatten_model(model, whitelist_keywords=None)#

flatten the modules in a model into a list whitelist_keywords: modules containing keywords will not be split

alpine.vis.geometry.local_complexity.get_intersections_for_hulls(hulls, model, layer_names, activation_buffer, batch_size=32, verbose=True, shift_output=False)#

sampler: sampling function to sample domain around each sample batch_size: number of samples to take for each forward pass. effective gpu batch_size is hull_n*batch_size

alpine.vis.geometry.local_complexity.get_layer_intersections_batched(layer_names, activation_buffer, batch_size=1)#

Input: layer_names: list with elements as strings or tuples of strings. activation_buffer: dictionary containing all activations

Output: Number and percentage of intersections for each member of layer_names

alpine.vis.geometry.local_complexity.get_ortho_hull_around_samples(x, r=1.0, n=10, seed=None)#

x: batchsize x channels x dim1 x dim2 r: max radius of hull n: number of samples

returns: s: batchsize x n_samples x channels x dim1 x dim2

alpine.vis.geometry.local_complexity.get_ortho_hull_around_samples_w_orig(x, r=1, n=11, seed=None)#

x: batchsize x channels x dim1 x dim2 r: max radius of hull n: number of samples

returns: s: batchsize x n_samples x channels x dim1 x dim2

alpine.vis.geometry.local_complexity.sample_ortho_random(n, d, seed=None)#
alpine.vis.geometry.local_complexity.split_generator(generator)#

Split tuple elements in a generator into lists

alpine.vis.geometry.partitions module#

class alpine.vis.geometry.partitions.partitions#

Bases: object

_summary_

Returns:

_description_

Return type:

_type_

device = device(type='cuda')#
static get_partitions_from_inr(x_bounds, y_bounds, model, signal_dims, sampled_points, sampled_points_batch_sizes=256)#

_summary_

Parameters:
  • x_bounds (_type_) – _description_

  • y_bounds (_type_) – _description_

  • model (_type_) – _description_

  • signal_dims (_type_) – _description_

  • sampled_points (_type_) – _description_

  • sampled_points_batch_sizes (int, optional) – _description_. Defaults to 256.

Returns:

_description_

Return type:

_type_

model_flatten_func(whitelist_keywords=None)#

flatten the modules in a model into a list whitelist_keywords: modules containing keywords will not be split

n = 4#
r = 0.0019#
show_partitions(normalize_each=False, title='', figsize=(10, 15), dpi=100)#

_summary_

Parameters:
  • partitions (_type_) – _description_

  • normalize_each (bool, optional) – _description_. Defaults to False.

  • title (str, optional) – _description_. Defaults to ‘’.

  • figsize (tuple, optional) – _description_. Defaults to (10,15).

  • dpi (int, optional) – _description_. Defaults to 200.

alpine.vis.geometry.partitions.plot_partitions(partition_images_set, normalize_each=False, title='', figsize=(10, 15), dpi=200)#

_summary_

Parameters:
  • partition_images_set (_type_) – _description_

  • normalize_each (bool, optional) – _description_. Defaults to False.

  • title (str, optional) – _description_. Defaults to ‘’.

  • figsize (tuple, optional) – _description_. Defaults to (10,15).

  • dpi (int, optional) – _description_. Defaults to 200.

alpine.vis.geometry.partitions.show_partitions(partitions, normalize_each=False, title='', figsize=(10, 15), dpi=100)#

_summary_

Parameters:
  • partitions (_type_) – _description_

  • normalize_each (bool, optional) – _description_. Defaults to False.

  • title (str, optional) – _description_. Defaults to ‘’.

  • figsize (tuple, optional) – _description_. Defaults to (10,15).

  • dpi (int, optional) – _description_. Defaults to 200.

Module contents#