-2

I am new and a very beginner of coding. Currently, I am planing to program an autoencoder for the features reduction by myself. Although I spent most of my time solving the error I got by taking a look at web sites and books, I am still suffering from debugging.

dtypes is float64(5) and Row and column is (37310, 5).

Any comments should be helpful. Thank you in advance!!

data1 = pd.read_csv("Omics small data3.csv")
df = pd.DataFrame(data1)
KA = df.as_matrix()
KA.shape

KA = Variable(np.array([37310, 5]).astype(np.float))
X = np.array(KA)

class MyAE(Chain):
    def __init__(self):
        super(MyAE, self).__init__(
                l1=L.Linear(500,100),
                l2=L.Linear(100,500),
        )
    def __call__(self,x):
            bv = self.fwd(x)
            return F.mean_squared_error(bv, x)
    def fwd(self,x):
            h1 = (self.l1(x))
            h2 = F.sigmoid(self.l2(h1))
            bv = self.l3(h2)
            return bv

model = MyAE()
optimizer = optimizers.SGD()
optimizer.setup(model)

n = 150
bs = 30

for i in range(0, n, bs):
    x = Variable(X)
    model.cleargrads()
    loss = model(x)
    loss.backword()
    optimizer.updata()

import matplotlib.pyplot as plt
x = Variable(X)
y = F.sigmoid(model.l1(x))
plt.scatter(x, y)
Anuraag Baishya
  • 874
  • 2
  • 11
  • 26

1 Answers1

0

Your input Variable and Linear layer dimension is not matched.

Please try l1=L.Linear(None,100) or l1=L.Linear(5,100)

If input size is None, appropriate size will be set automatically.

fukatani
  • 190
  • 6
  • Thank you very much for your help, fukatani-san. Yes, I was able to fixt this problem finally. I am learning through a trial and error process. Thank you again. – user9690450 May 07 '18 at 23:12