def get_saliency_map_steps(matrix) -> list: global graph with graph.as_default(): processed_matrix = transform.process_matrix(matrix, MATRIX_DIM) gradients = saliency_calculation.get_gradients(processed_matrix) # only_max_before= transform.sign(gradients) scaled_gradients = transform.scaleMatrix(gradients) # only_max= transform.sign(scaled_gradients) filled_matrix = transform.replace_positive_values( matrix, scaled_gradients) return [ { "1. matrix": matrix }, { "2. processed matrix": processed_matrix }, { "3. gradients": gradients }, # {"3.5 only_max_before :": only_max_before}, { "4. scaled gradients": scaled_gradients }, # {"4.5. only_max :": only_max}, { "5. filled matrix:": filled_matrix }, ]
def get_saliency_map(matrix) -> list: global graph with graph.as_default(): processed_matrix = transform.process_matrix(matrix, MATRIX_DIM) gradients = np.array( saliency_calculation.get_gradients(processed_matrix)) _replace_negatives(gradients) filled_matrix = transform.replace_positive_values(matrix, gradients) return filled_matrix
def get_network_score(matrix) -> list: global graph with graph.as_default(): matrix = transform.process_matrix(matrix, MATRIX_DIM) return _predict_badness(matrix)