1. 概要
前ページと同様の状況で・・・。
本ページは、下記のサイトを参考にさせていただきました。
「python - TypeError: 'torch.dtype' object is not callable. how to call this function?」
2. 現象
プログラムがこけたのは。
ai8x-training/ai8x.py
の。
def _conv_forward(self, x, weight, bias): # pylint: disable=method-hidden
return nn.functional.linear(x, weight, bias)
下記のようなエラーになります。
RuntimeError: expected m1 and m2 to have the same dtype, but got: __int64 != float
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> パス\ai8x-training\ai8x.py(1337)_conv_forward()
-> return nn.functional.linear(x, weight, bias)
3. 対処
「x」が、「__int64」の行列なのに対して、「weight」は、「float」の行列なので、演算ができない、いうとるですな。
データを読み込んで、行列を生成しているのが・・・。
起動時のスクリプトに。
--dataset xxx
てな記述をしておりまして、この「datase」ちゅうのを。
ai8x-training/datasets/xxx.py
ai8x-training/datasets/xxx_dataframe_parser.py
てなモジュールで定義しておりまして。
上のモジュールは、下のモジュールを継承しております。
上のモジュールに。
from .xxx_dataframe_parser import Xxx_DataFrame_Parser
・・・ 略 ・・・
def __getitem__(self, index):
label = torch.tensor(self.data_list[index][1], dtype=torch.int64)
signal = super().__getitem__(index)
return signal, label
下のモジュールに。
def __getitem__(self, index):
if index >= len(self):
raise IndexError
if self.is_truncated:
index = 0
file, nop = self.data_list[index]
・・・ 略 ・・・
signal = torch.tensor(df.values)
return signal
てな記述をしております。
とりあえず、ここでは、下のモジュールの「return」の前に。
signal = signal.to(torch.float)
ちゅう行をいれることで、先へ進めます。