【问题标题】:SyntaxError: invalid syntax when training a neural network modelSyntaxError:训练神经网络模型时语法无效
【发布时间】:2021-06-21 14:17:09
【问题描述】:

我正在尝试训练模型 (https://github.com/bmild/nerf),但在运行 this 代码时出现以下错误。

部分代码为:

def recenter_poses(poses):
poses_ = poses+0
bottom = np.reshape([0,0,0,1.], [1,4])
c2w = poses_avg(poses)
c2w = np.concatenate([c2w[:3,:4], bottom], -2)
bottom = np.tile(np.reshape(bottom, [1,1,4]), [poses.shape[0],1,1])
poses = np.concatenate([poses[:,:3,:4], bottom], -2)

poses = np.linalg.inv(c2w) @ poses
poses_[:,:3,:4] = poses[:,:3,:4]
poses = poses_
return poses

错误:

Traceback (most recent call last):   
File "run_nerf.py", line 12, in <module>
     from load_llff import load_llff_data   
File "/home/DNN/Softwares/nerf-master/load_llff.py", line 176
     poses = np.linalg.inv(c2w) @ poses
                                ^ SyntaxError: invalid syntax``

非常感谢任何帮助!我对此很陌生。谢谢:)

【问题讨论】:

  • @ 矩阵乘法运算符was introduced in Python 3.5。看起来您是在较早的 Python 版本上运行此代码
  • 啊,好吧。非常感谢!

标签: python numpy neural-network training-data


【解决方案1】:

@ 在 Python 3.5 之前不受支持。如果您有旧版本,也许您可​​以使用 numpy.dot 以这种方式运行:

poses = np.dot(np.linalg.inv(c2w), poses)

PEP465

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-05-03
  • 1970-01-01
  • 2019-11-16
  • 2020-08-24
  • 2011-04-07
  • 1970-01-01
  • 2015-06-11
相关资源
最近更新 更多