# Errors occur when using deep learning models

**URL:** <https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350>\
**Category:** Flower Help - Beginners\
**Created:** [October 15, 2024, 8:50pm UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350 "2024-10-15T20:50:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![thefool](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@thefool](https://discuss.flower.ai/u/thefool)\
**Post date:** [October 15, 2024, 8:50pm UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/1 "2024-10-15T20:50:26Z")

</div>

Hi, I replace the model in the tutorials with deep learning models like ResNet and DenseNet, errors occur during the simulation: in \_load\_from\_state\_dict input\_param = input\_param[0]  
IndexError: index 0 is out of bounds for dimension 0 with size 0.  
I have no idea how to solve it since there’s no error when I train and test the deep learning model without federated learning.

---

<div class="post-metadata">

**Author:** ![chongshenng](https://dub1.discourse-cdn.com/flex013/user_avatar/discuss.flower.ai/chongshenng/32/153_2.png) [@chongshenng](https://discuss.flower.ai/u/chongshenng)\
**Post date:** [October 23, 2024, 7:09am UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/2 "2024-10-23T07:09:48Z")

</div>

Hello @thefool. It looks maybe like an issue with converting the model weights to `NDArrays`. Can you share more details of the error and/or your code?

---

<div class="post-metadata">

**Author:** ![thefool](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@thefool](https://discuss.flower.ai/u/thefool)\
**Post date:** [October 23, 2024, 1:40pm UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/3 "2024-10-23T13:40:34Z")

</div>

Thanks for the reply.  
I just replace the model in the tutorial with the models pytorch have and modify them to satisfy the input and output size of CIFAR-10. For example:  
net=densenet121() net.classifier = nn.Linear(1024, 10) OR  
class CIFAR10ResNet(nn.Module):  
def **init** (self):  
super(CIFAR10ResNet, self). **init** ()  
self.resnet = models.resnet18(weights=None)  
self.resnet.conv1 = nn.Conv2d(3, 64, kernel\_size=3, stride=1, padding=1, bias=False)  
self.resnet.maxpool = nn.Identity()  
self.resnet.fc = nn.Linear(512, 10)  
def forward(self, x):  
return self.resnet(x)

---

<div class="post-metadata">

**Author:** ![thefool](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@thefool](https://discuss.flower.ai/u/thefool)\
**Post date:** [October 23, 2024, 1:41pm UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/4 "2024-10-23T13:41:55Z")

</div>

I would appreciate it if anyone could replace the model in the tutorials with models like ResNet and DenseNet to see if they can work.

---

<div class="post-metadata">

**Author:** ![chongshenng](https://dub1.discourse-cdn.com/flex013/user_avatar/discuss.flower.ai/chongshenng/32/153_2.png) [@chongshenng](https://discuss.flower.ai/u/chongshenng)\
**Post date:** [October 23, 2024, 3:23pm UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/5 "2024-10-23T15:23:49Z")

</div>

That’s a good suggestion. In our old examples, we used `MobileNetV2` (see [this](https://flower.ai/docs/framework/v1.8.0/en/tutorial-quickstart-tensorflow.html#flower-client) for example) but no longer include that in our examples. Perhaps it’s worth doing so now.

Would you be willing to contribute an example @thefool?

---

<div class="post-metadata">

**Author:** ![thefool](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@thefool](https://discuss.flower.ai/u/thefool)\
**Post date:** [October 24, 2024, 4:24am UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/6 "2024-10-24T04:24:51Z")

</div>

But as I state in this post when I want to use deep learning models to replace the models in the flower tutorials I meet errors. Sorry I can’t contribute an example.

---

<div class="post-metadata">

**Author:** ![wittenator](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@wittenator](https://discuss.flower.ai/u/wittenator)\
**Post date:** [October 24, 2024, 10:36am UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/7 "2024-10-24T10:36:22Z")

</div>

I added a more complete minimum reproducible example in the corresponding Github issue: [State dict creation bug for e.g. resnet18 · Issue #4344 · adap/flower · GitHub](https://github.com/adap/flower/issues/4344)

---

<div class="post-metadata">

**Author:** ![thefool](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@thefool](https://discuss.flower.ai/u/thefool)\
**Post date:** [October 24, 2024, 10:55am UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/8 "2024-10-24T10:55:10Z")

</div>

Thank you for the solution!

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/flower/original/1X/bc7fe36843c391cbd0b4e8b6f48275961d356abc.png) [@system](https://discuss.flower.ai/u/system)\
**Post date:** [October 31, 2024, 10:55am UTC](https://discuss.flower.ai/t/errors-occur-when-using-deep-learning-models/350/9 "2024-10-31T10:55:13Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
