我是新手,也是编码的初学者。目前,我正计划自己编写一个自动编码器来减少功能。虽然我大部分时间都在通过查看网站和书籍来解决我遇到的错误,但我仍然在调试。
dtypes 是 float64(5),行和列是 (37310, 5)。
任何评论都应该有帮助。先感谢您!!
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)