How would you implement this framework in pytorch?

EMYR: <p>Hi I am a newbie to pytorch and DL, and I am trying to implement this paper<br>
<a href="https://pdf.sciencedirectassets.com/271522/1-s2.0-S0165011419X00093/1-s2.0-S0165011418303324/main.pdf?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEG4aCXVzLWVhc3QtMSJIMEYCIQCc3Lf3BcikbHviUk1JBe5JiErVRnTME6jeoHt2a%2FAhoQIhAP81lOob4%2BfcrmMWyatJWAQpPPQKUrOu34Dh7kGyg6H9KrwFCOf%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQBRoMMDU5MDAzNTQ2ODY1IgwEutP3wrmyl9vrZKsqkAW22mf0dUXqE%2B4yxC5yNQmefeJi9g%2F9cOrVlDFp%2BjO6pWbfTyKgDE%2BflEUMnYZC4lUkgSdugF87xcSJ%2BRX%2F2aV6%2BuYzirnkDF%2F3x4YL24GVJI43MFLpBWwzrxtTR9dm53AlVyGr2g09JRgYRpl3a91ccqzHWe7flZtZEFYkRg1l5qxTdsGVzJBWfk5BrkCOdo0BuOLyrxnyPjKMiV1JY2N4Co%2FHElQMnNEDlSofdp816KRQUWX2fdIWyinomsava2uojcD%2B4dSAAaQwsThO8sZdjXyO%2FcXsXPjEtwte5wDAZTEtKsivbeInkG1JB1OIvBXJZSAvybkLq39BuI4LUvYG58vuYP7zC01BEZxb3By5xEVIwOarnAyQFVjMaDEH5ZC0hjYiT8HKTbtXDJrfe4uuHWXhG0omy1vPeOqcGkTGh0zo3IUfII%2BQy3Bvd0DRctPTiw98EPVth5EeUABTnz92XZJTzvI%2FabBIRE5THWCK0Byk%2BIr6BRVoL%2Fhqi%2FFeDPpgWBT31c3upzzujmUzE5bF52KUOh5nMlNSstGuSaNdPd5MvjYRs0HWE7mIN%2BE18ls9QtUkPO05D67ka2oFjQCgRZWKnRlMaqJWP%2Br70uecnaY7n%2F4%2FJwX1Efwc%2BGsTLaiS8Glx6SrQ4Pm5iyn54Nxte0AwsjwlLqjprcr1sjFKBRXbG3rvPuUi39Z5ziyeUWQo8E9DVrghzZmzRDTMHPdkBRopb4MjmHbUuIdmiZce201Af7xUQIqfExk3Uu%2FcG4nbjy3hGLFuwEpy1vA7E%2Fv6MTvCdgzAvlMcxCjQWe1eVDAYELxfk2iC98Ub0PxkDIW28Bsd7lVFGmZqHeYOlt3RR8cR1y21TA67EePnLxmw4DCu39WyBjqwATVH%2FjZiTOxkyPteT0ivbJUXQ4OwDi4vHZBwyZJEIUJJQevoZB2BnEF3gTY3%2F5NQUSrZjTvdhhvVwVxkKWTUU4El9Di14oQ0UxxaPOHQMBvztQyeydUpKfMpbS7lBN5Ko7DnzcTfidKXGtERy5bcaLfphzNpgq3o8d%2Fhq7AcF7%2BDgQ9utGbA8%2BdPRwUK2%2BLiuLIOxo2X3ExrlRl6cctokkZ7R%2F1kxM7vp1VJuhpsqmrP&amp;X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Date=20240528T071617Z&amp;X-Amz-SignedHeaders=host&amp;X-Amz-Expires=300&amp;X-Amz-Credential=ASIAQ3PHCVTYUTT3HTWD%2F20240528%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Signature=066df8d1fd2b0d957a4124d30f66c5b0164190ef50bde354de3f9ee04c6d43a3&amp;hash=55105131202b87c1b74c6a325fb80c9777a4a0b17cbeb0459936e755c7fc5c90&amp;host=68042c943591013ac2b2430a89b270f6af2c76d8dfd086a07176afe7c76c2c61&amp;pii=S0165011418303324&amp;tid=spdf-a15d24a4-4d08-4e1c-b710-57867fb6fb9b&amp;sid=adfdac746b7398455e19d07803627a32e425gxrqb&amp;type=client&amp;tsoh=d3d3LnNjaWVuY2VkaXJlY3QuY29t&amp;ua=0a0b5e590304585a5b&amp;rr=88ac75559e57665e&amp;cc=nl" rel="noopener nofollow ugc">Paper</a>, with epochs, batch loaders and SGD.</p>
<p>Is this the correct approach ?</p>
<pre><code>opt_centers = optim.SGD(centers,lr)
loss = 0
u = None
for e in epochs : 
 while not ( C_cconverged and U_converged):
      for batch in loader: 
           opt.zerograd()
           u = update_U(X)
           loss = 
           loss.backward(retain_graph= True)
           loss_F += loss 
           opt_centers.step
           
           if C &lt; treshold and U &lt; treshold:
               C_cconverged = U_converged = True
               break
 while not ( W_converged):
      for batch in loader:
           #  proximal operator
           W_prox= update_W()
           G_loss +=  G_loss_function(W_prox)
           if W_prox &lt; treshold:
               C_cconverged = U_converged = True
               break
 if W_converged :
      for batch in loader: 
           opt.zerograd()
           u = update_U(X)
           loss = 
           loss.backward(retain_graph= True)
           loss_F += loss 
           opt_centers.step
 
      return model.centers,u
</code></pre>

AlphaBetaGamma96: <p>Hi <a class="mention" href="/u/emyr">@EMYR</a>,</p>
<p>There are a few mistakes in your code,</p>
<pre><code class="lang-auto">opt.zerograd() #should be opt_centers.zero_grad()
opt_centers.step #should be opt_centers.step()
</code></pre>