# Zygote/Flux not computing gradient with view/slice of tensor properly for MLP

**URL:** <https://discourse.julialang.org/t/zygote-flux-not-computing-gradient-with-view-slice-of-tensor-properly-for-mlp/67835>\
**Category:** Machine Learning\
**Created:** [September 7, 2021, 10:17pm UTC](https://discourse.julialang.org/t/zygote-flux-not-computing-gradient-with-view-slice-of-tensor-properly-for-mlp/67835 "2021-09-07T22:17:43Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![outlace](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/outlace/32/2216_2.png) [@outlace](https://discourse.julialang.org/u/outlace)\
**Post date:** [December 4, 2021, 3:47pm UTC](https://discourse.julialang.org/t/zygote-flux-not-computing-gradient-with-view-slice-of-tensor-properly-for-mlp/67835/17 "2021-12-04T15:47:34Z")

</div>

Well there is still more fiddling to be done to maybe improve its performance. For example, I wonder if manually computing gradients would be faster as Zygote has a hard time with the matrix subsampling. I am also primarily interested in implementing SLIDE for computer vision applications, so I can do training and inference on a CPU. I was planning on implementing one of the new MLP-based vision networks like MLP-Mixer ( [https://papers.nips.cc/paper/2021/file/cba0a4ee5ccd02fda0fe3f9a3e7b89fe-Paper.pdf](https://papers.nips.cc/paper/2021/file/cba0a4ee5ccd02fda0fe3f9a3e7b89fe-Paper.pdf) ) using SLIDE to see if that would work.

I uploaded my experiments to this git repo: [GitHub - outlace/SLIDE-Pose-Estimation](https://github.com/outlace/SLIDE-Pose-Estimation)

So I was able to get Zygote to get gradients but Flux’s built in optimizer doesn’t seem to work with my SLIDE implementation, so I had to write an ADAM optimizer from scratch, that’s in the optim.jl file.

---

_[View the full topic](https://discourse.julialang.org/t/zygote-flux-not-computing-gradient-with-view-slice-of-tensor-properly-for-mlp/67835)._
