ディープラーニングアルゴリズムのコードを記述しました。しかし、私はちょうどデータをロードする最後の段階で立ち往生しています。TensorType(float32、matrix)をTensorType(int32、matrix)に変換する際のエラー
self.x = T.imatrix("x")
self.y = T.ivector("y")
は、データを保持する変数として定義されている
、私はやる
train_x, train_y, train_lengths = dataUtils.read_and_sort_matlab_data(path+"train.txt",path+"train_lbl.txt")
validate_x, validate_y, validate_lengths = dataUtils.read_and_sort_matlab_data(path+"valid.txt",path+"valid_lbl.txt")
tested_x, tested_y, tested_lengths = dataUtils.read_and_sort_matlab_data(path+"test.txt",path+"test_lbl.txt")
ここ
私は train_yは形状の型numpy.ndarrayのある変数の型を確認している(2000年、) とtrain_y [0]のタイプが 'int32'です。
その後、私は
def shared(data_x,data_y):
shared_x = theano.shared(np.asarray(data_x, dtype=theano.config.floatX), borrow=True)
shared_y = theano.shared(np.asarray(data_y, dtype=theano.config.floatX), borrow=True)
return shared_x, T.cast(shared_y, "int32")
を次のように共有機能が定義されている場所、私は次のコード
train_mb = theano.function(
[i], cost, updates=updates,
givens={
self.x:
training_x[i*self.document_length: (i+1)*self.document_length],
self.y:
training_y[i: (i+1)]
})
でエラーを取得する変数
training_x,training_y = shared(train_x,train_y)
validation_x,validation_y = shared(validate_x,validate_y)
test_x,test_y = shared(tested_x,tested_y)
を共有theanoにデータを置きますラインで
training_y[i: (i+1)]
エラーが
TypeError例外である:タイプTensorType(INT32、マトリックス)に入力TensorType(0。可変サブテンソルの{:int64モードのInt64})(のfloat32、マトリックス)を変換できません。 Subtensor {int64:int64:}。0を手動でTensorType(int32、matrix)に変換することができます。
私はすでにshared_y変数をキャストしているときに、float32が導入されている場所を誰かが知ることができますか?そしてこのエラーを修正する方法。また、なぜtrain_yがそのような形で提案されたベクトルであるのか、エラー文には行列がありますか?