BioExp.graphs package

Submodules

BioExp.graphs.causal module

BioExp.graphs.concept module

class BioExp.graphs.concept.ConceptGraph(model, weights_pth, metric, layer_names, max_clusters=None)[source]

Bases: object

A class for generating concept graph on a trained keras model instance

generate_fmaps(nodeA_info, nodeB_info, dataset_path, loader, save_path)[source]

get link between two nodes, nodeA, nodeB occlude at nodeA and observe changes in nodeB

nodeA_info : {‘layer_name’, ‘layer_idxs’} nodeB_info : {‘layer_name’, ‘layer_idxs’}

generate_graph(graph_info, dataset_path=None, loader=None, save_path=None)[source]

generates graph adj matrix for computation

graph_info: {‘concept_name’, ‘layer_name’, ‘feature_map_idxs’} save_path : graph_path or path to save graph

links is some norm information of feature activation maps

fmaps: activation maps

get_concepts(save_path)[source]

Define node and generates json map

save_path : path to save json graph

get_layer_idx(layer_name)[source]

BioExp.graphs.delta module

class BioExp.graphs.delta.DeltaGraph(model, weights_pth, metric, classinfo=None)[source]

Bases: object

A class for generating concept graph on a trained keras model instance

generate_graph(graph_info, dataset_path=None, loader=None, save_path=None, max_samples=1, nmontecarlo=10)[source]

generates graph adj matrix for computation

graph_info: [{‘concept_name’, ‘layer_name’, ‘filter_idxs’}] save_path : graph_path or path to save graph

get_layer_idx(layer_name)[source]

get link between two nodes, nodeA, nodeB occlude at nodeA and observe changes in nodeB

nodeA_info : {‘layer_name’, ‘layer_idxs’} nodeB_info : {‘layer_name’, ‘layer_idxs’}

node_significance(graph_info, dataset_path=None, loader=None, save_path=None, max_samples=1, nmontecarlo=10)[source]

generates graph adj matrix for computation

graph_info: {‘concept_name’, ‘layer_name’, ‘feature_map_idxs’} save_path : graph_path or path to save graph

significance_test(concept_info, dataset_path, loader, nmontecarlo=10, max_samples=1)[source]

test significance of each concepts

concept: {‘concept_name’, layer_name’, ‘filter_idxs’}

BioExp.graphs.significance module

class BioExp.graphs.significance.SignificanceTester(model, weights_pth, metric, classinfo=None)[source]

Bases: object

A class for testing significance of each concepts generated in a trained keras model instance

get_layer_idx(layer_name)[source]
graph_significance(graph_info, dataset_path=None, loader=None, save_path=None, max_samples=1, nmontecarlo=10)[source]

generates graph adj matrix for computation graph_info: {‘concept_name’, ‘layer_name’, ‘feature_map_idxs’} save_path : graph_path or path to save graph

node_significance(concept_info, dataset_path, loader, nmontecarlo=10, max_samples=1)[source]

test significance of each concepts concept: {‘layer_name’, ‘filter_idxs’}

Module contents