尝试运行AutoEncoder时出现nolearn错误

时间:2015-12-13 14:02:30

标签: python neural-network theano deep-learning nolearn

我正在尝试使用nolearn运行简单的自动编码器:

import nolearn
from nolearn.dbn import DBN
from sklearn.cross_validation import train_test_split
data=np.load('doc_user_matrix.npy')
print (data.shape) #outputs: (10000,500)

(x_train, x_test, y_train, y_test)=train_test_split(data,data,test_size = 0.33)

hidden_layer=10

ae = DBN([x_train.shape[0], hidden_layer, x_train.shape[0]],
                learn_rates = 0.3,
                learn_rate_decays = 0.9,
                epochs = 10)

ae.fit(x_train, x_train)

出于某种原因,我遇到了这个错误:

  

ValueError:输入形状错误(10000,500)

任何人都可以解释为什么会出现这种错误,以及如何解决它?

1 个答案:

答案 0 :(得分:1)

通常第二个维度对应于要素,而第一个维度对应于实例。尝试:

[x_train.shape[1], hidden_layer, x_train.shape[1]]