1

I am trying to train a model (https://github.com/bmild/nerf), and I am getting the error below when I run this code.

The part of the code is:

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

The error:

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``

I really appreciate any help! I am new at this. Thanks :)

o-90
  • 17,045
  • 10
  • 39
  • 63
  • 2
    The `@` matrix multiplication operator [was introduced in Python 3.5](https://stackoverflow.com/questions/27385633/what-is-the-symbol-for-in-python). Looks like you're running this code on an earlier Python version – ForceBru Mar 24 '21 at 19:54
  • Ah okay. Thanks very much! – Tanya Stevens Mar 24 '21 at 20:00

1 Answers1

2

The @ is not supported before Python 3.5. If you have an older version, perhaps you can run this way using numpy.dot:

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

PEP465

Renan Lopes
  • 411
  • 4
  • 16