fe5db3121c4313775181dea4935c764b84b8d357,keract/keract.py,,get_gradients_of_activations,#,23

Before Change


     Gets gradient a layer output for given inputs and outputs
    // grads = model.optimizer.get_gradients(model.total_loss, model.layers[layer].output)
    layer_names = [l.output.name for l in model.layers]
    grads = model.optimizer.get_gradients(model.total_loss, [l.output for l in model.layers])
    output_grad = _evaluate(model, grads, model_inputs, outputs)
    result = dict(zip(layer_names, output_grad))
    return result


def get_activations(model, model_inputs, layer_name=None):
    outputs = [layer.output for layer in model.layers if layer.name == layer_name or layer_name is None]

After Change


def get_gradients_of_activations(model, x, y, layer_name=None):
    nodes = [layer.output for layer in model.layers if layer.name == layer_name or layer_name is None]
    nodes_names = [n.name for n in nodes]
    return _get_gradients(model, x, y, nodes, nodes_names)


def _get_gradients(model, x, y, nodes, nodes_names):
    if model.optimizer is None:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: philipperemy/keras-activations
Commit Name: fe5db3121c4313775181dea4935c764b84b8d357
Time: 2019-01-03
Author: premy@cogent.co.jp
File Name: keract/keract.py
Class Name:
Method Name: get_gradients_of_activations


Project Name: robertmartin8/PyPortfolioOpt
Commit Name: 5e56bcc41a7d147c710e57c4c764651c7e148581
Time: 2020-04-30
Author: thomas.schmlezer@gmail.com
File Name: pypfopt/hierarchical_portfolio.py
Class Name: HRPOpt
Method Name: _get_quasi_diag


Project Name: robertmartin8/PyPortfolioOpt
Commit Name: 70b08e1d2e703b4e3d16da9aaa04706dd4413232
Time: 2020-05-01
Author: thomas.schmlezer@gmail.com
File Name: pypfopt/hierarchical_portfolio.py
Class Name: HRPOpt
Method Name: _get_quasi_diag