私は theano とその LeNet チュートリアルを使用して、ストリート ビューの Google 画像のデータセットで CNN をトレーニングしています。
データセットをロードします。
train_set_x, train_set_y, \
valid_set_x, valid_set_y, \
test_set_x, test_set_y = manager.get_grayscale_data_dim()
寸法を印刷します:
self.train_data_dims (70000, 1024, 1)
self.train_labels_dims (70000, 1)
self.valid_data_dims (3250, 1024, 1)
self.valid_labels_dims (3250, 1)
self.test_data_dims (26000, 1024, 1)
self.test_labels_dims (26000, 1)
次に、チュートリアルのようにします:
# allocate symbolic variables for the data
index = T.lscalar() # index to a [mini]batch
x = T.matrix('x') # the data is presented as rasterized images
y = T.ivector('y') # the labels are presented as 1D vector of
print "y.type", y.type, "y.ndim", y.ndim
print "test_set_y", test_set_y.type, "test_set_y.ndim", test_set_y.ndim
印刷された結果:
y.type TensorType(int64, vector) y.ndim 1
test_set_y TensorType(int64, vector) test_set_y.ndim 1
ここで問題が発生します (これは定義された最初の関数であり、次は検証とトレーニングです。名前が混乱しないようにするためであり、同様のトレーニング関数と検証関数ですべてがうまくいったとは思わないでください):
モデルが犯した間違いを計算する関数を作成する
test_model = theano.function(
[index],
layer3.errors(y),
givens={
x: test_set_x[index * batch_size: (index + 1) * batch_size],
y: test_set_y[index * batch_size: (index + 1) * batch_size]
}
)
正確には、次の行にエラーがあります。
y: test_set_y[index * batch_size: (index + 1) * batch_size]
エラー自体は、(afaiu) smth を行列に変換しようとしていると言っています。これはどこで起こっているのだろうか?
TypeError: Cannot convert Type TensorType(float64, vector) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(float64, matrix). You can try to manually convert Subtensor{int64:int64:}.0 into a TensorType(float64, matrix).
私の知る限り、y と test_set_y の次元は一致しています。私のコードでは、どちらも 1D ベクトルです。 スライスによってエラーが発生するのはなぜですか? スライスはマトリックスを作成しますか? さらに重要なことに、この問題を解決するにはどうすればよいですか? 前もって感謝します!
よろしくお願いします。