# How to modify the final FC layer based on the torch.model

**URL:** <https://discuss.pytorch.org/t/how-to-modify-the-final-fc-layer-based-on-the-torch-model/766>\
**Category:** Uncategorized\
**Created:** [February 27, 2017, 12:46pm UTC](https://discuss.pytorch.org/t/how-to-modify-the-final-fc-layer-based-on-the-torch-model/766 "2017-02-27T12:46:27Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Cysu](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/cysu/32/113_2.png) [@Cysu](https://discuss.pytorch.org/u/Cysu)\
**Post date:** [March 1, 2017, 3:31am UTC](https://discuss.pytorch.org/t/how-to-modify-the-final-fc-layer-based-on-the-torch-model/766/12 "2017-03-01T03:31:27Z")

</div>

That’s because vgg19 doesn’t have a `fc` member variable. Instead, it has a

```python
  (classifier): Sequential (
    (0): Dropout (p = 0.5)
    (1): Linear (25088 -> 4096)
    (2): ReLU (inplace)
    (3): Dropout (p = 0.5)
    (4): Linear (4096 -> 4096)
    (5): ReLU (inplace)
    (6): Linear (4096 -> 100)
  )

```

To replace the last linear layer, a temporary solution would be

```python
vgg19.classifier._modules['6'] = nn.Linear(4096, 8)

```

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-modify-the-final-fc-layer-based-on-the-torch-model/766)._
