Hi, sorry for the delay. I am not sure if this is what you are looking for.
But, Please take a look at this:

  
      gist.github.com
  
  
    https://gist.github.com/InnovArul/500e0c57e88300651f8005f9bd0d12bc 491
tied_linear.py
import torch, torch.nn as nn, torch.nn.functional as F
import numpy as np
import torch.optim as optim

# tied autoencoder using off the shelf nn modules
class TiedAutoEncoderOffTheShelf(nn.Module):
	def __init__(self, inp, out, weight):
		super().__init__()
		self.encoder = nn.Linear(inp, out, bias=False)
		self.decoder = nn.Linear(out, inp, bias=False)
This file has been truncated. show original




  
  
    
    
  
  


I have tried to use two linear layers and shared their weights, as well as tried to use F.linear.
Hope, it helps.