0、环境
python 3.8.19
torch 1.12.1+cu113
1、处理数据
运行”process_data.py“,得到”processed_data_noise“文件夹
1、config,dataset设置
1.1设置datasetmain.py中的config、dataset
condig为’configs/baseline.yaml’
dataset从[“eth”, “hotel”, “univ”, “zara1”, “zara2”, “sdd”]中选一个
1.2运行main.py报错找不到文件夹
将baseline.yaml中的”data_dir: processed_data“修改为”data_dir: processed_data_noise“
2、AttributeError: module ‘numpy’ has no attribute ‘float’.
GPT回答:
这个错误消息表明你在使用 np.float,它是 Python 中已经被弃用的别名,代表内置的 float 类型。为了避免这个错误,你应该直接使用 float,而不是 np.float。如果你需要使用 NumPy 的标量类型,可以使用 np.float64。
因此,你可以根据需求将 np.float 替换为 float 或 np.float64。
例如:
将 np.float 替换为 float
x = float(5.0)
或者将 np.float 替换为 np.float64
y = np.float64(5.0)
这样的修改将防止你遇到的 AttributeError 错误。
于是进行修改
scene_graph.py中的
dist_cube = np.zeros((total_timesteps, N, N), dtype=np.float)
修改为
dist_cube = np.zeros((total_timesteps, N, N), dtype=float)
node_attention_mat = np.zeros((N, N), dtype=np.float)
修改为
node_attention_mat = np.zeros((N, N), dtype=
float)
3、IndexError: tensors used as indices must be long, byte or bool tensors
GPT说:
主要错误:张量索引中的 IndexError
当你尝试使用一个张量作为另一个张量的索引时,出现错误 IndexError: tensors used as indices must be long, byte or bool tensors。这表示用作索引的张量不是 PyTorch 允许用于索引的数据类型(即,应该是 long、byte 或 bool 类型)。以下是如何解决这个问题:
检查数据类型:确保用于索引的张量 last_index_per_sequence 是正确的数据类型。如果它不是,你可以显式地将它转换为 long 类型:
last_index_per_sequence = last_index_per_sequence.long()
将
中的
last_index_per_sequence = -(first_history_indices + 1)
后增加
last_index_per_sequence = last_index_per_sequence.long()
(536行和616行)