# Tutorials/examples of captum with 1D data?

**URL:** <https://discuss.pytorch.org/t/tutorials-examples-of-captum-with-1d-data/225162>\
**Category:** Captum\
**Created:** [July 9, 2026, 9:43pm UTC](https://discuss.pytorch.org/t/tutorials-examples-of-captum-with-1d-data/225162 "2026-07-09T21:43:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tessarion](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/t/c4cdca/32.png) [@tessarion](https://discuss.pytorch.org/u/tessarion)\
**Post date:** [July 9, 2026, 9:43pm UTC](https://discuss.pytorch.org/t/tutorials-examples-of-captum-with-1d-data/225162/1 "2026-07-09T21:43:06Z")

</div>

Hello all,

I’m hoping to use captum for feature attribution on a basic 1-D linear regression model (see below), but all the examples I’ve seen use 2D models (usually for machine vision applications). Is there a good tutorial out there for using captum with simpler models?

Thanks!

```python
class Regression(nn.Module):

  def __init__ (self):
    super(). __init__ ()
    self.layers = nn.Sequential(
      nn.Linear(7490, 64),
      nn.ReLU(),
      nn.Linear(64, 32),
      nn.ReLU(),
      nn.Linear(32, 1)
    )

  def forward(self, x):
    '''
      Forward pass
    '''
    return self.layers(x)

def training_loop(n_epochs, train_loader):
# training loop

    for epoch in range(n_epochs):

        # Set current loss value
        current_loss = 0.0
        # Iterate over the DataLoader for training data
        for i, data in enumerate(train_loader, 0):
          # Get and prepare inputs
          inputs, targets = data
          inputs, targets = inputs.float(), targets.float()
          targets = targets.reshape((targets.shape[0],1))
            # Zero the gradients
          optimizer.zero_grad()
          # Perform forward pass
          outputs = model(inputs)

          # Compute loss
          loss = loss_function(outputs, targets)

          # Perform backward pass
          loss.backward()

          # Perform optimization
          optimizer.step()
    return model

```

---

<div class="post-metadata">

**Author:** ![KevinTurner](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/k/7993a0/32.png) [@KevinTurner](https://discuss.pytorch.org/u/KevinTurner)\
**Post date:** [July 11, 2026, 12:33pm UTC](https://discuss.pytorch.org/t/tutorials-examples-of-captum-with-1d-data/225162/2 "2026-07-11T12:33:48Z")

</div>

Captum works with 1D models too. Most of the examples use images, but the attribution methods are model agnostic. For a simple feed forward network like yours, methods such as Integrated Gradients or Saliency should work without changing the model. The main difference is that your input tensor will have shape `[batch_size, 7490]` instead of image dimensions. The image examples still apply once you replace the input format.
