In a single hidden layered neural network, how do I calculate sensitivity of each input parameter on the output of the result?
7 ビュー (過去 30 日間)
古いコメントを表示
I have created a three layered neural network. The input layer consists of 11 parameters, the hidden layer has 15 nodes and one node in the output layer. I want to see/calculate the changes in the output with respect to each of the input parameter. Basically sensitivity of the input parameters on the output of the network.
0 件のコメント
回答 (1 件)
Aditya
2025 年 8 月 28 日 9:46
Hi Sunil,
To assess how each input parameter affects the output of your neural network, you can calculate the sensitivity of the output with respect to each input by computing the partial derivatives of the output with respect to each input parameter. This gives you a vector of sensitivities, indicating how much the output would change for a small change in each input, holding the others constant. Modern deep learning frameworks like PyTorch or TensorFlow make this straightforward using automatic differentiation. Below is an example in PyTorch that demonstrates how to compute these sensitivities for a network with 11 input features, a hidden layer of 15 nodes, and a single output node:
import torch
import torch.nn as nn
# Define the neural network structure
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.fc1 = nn.Linear(11, 15)
self.relu = nn.ReLU()
self.fc2 = nn.Linear(15, 1)
def forward(self, x):
x = self.fc1(x)
x = self.relu(x)
x = self.fc2(x)
return x
# Instantiate the network
net = Net()
# Example input (batch size 1, 11 features)
x = torch.randn(1, 11, requires_grad=True)
# Forward pass
output = net(x)
# Compute gradients (sensitivities)
output.backward()
# Sensitivities: dy/dx for each input
sensitivities = x.grad.data # shape: [1, 11]
print("Sensitivities:", sensitivities)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!