question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tensor' object has no attribute 'index

See original GitHub issue

python version: anaconda3/python 3.6 PyTorch Version: 0.4.1 Torchvision Version: 0.2.1 Linux 18.04 marvin@marvin:~/Code/Pytorch/faster-rcnn.pytorch$ python trainval_net.py --cuda Called with args: Namespace(batch_size=1, checkepoch=1, checkpoint=0, checkpoint_interval=10000, checksession=1, class_agnostic=False, cuda=True, dataset=‘pascal_voc’, disp_interval=100, large_scale=False, lr=0.001, lr_decay_gamma=0.1, lr_decay_step=5, mGPUs=False, max_epochs=1, net=‘vgg16’, num_workers=1, optimizer=‘sgd’, resume=False, save_dir=‘data/pretrained_model’, session=1, start_epoch=1, use_tfboard=False) Using config: {‘ANCHOR_RATIOS’: [0.5, 1, 2], ‘ANCHOR_SCALES’: [8, 16, 32], ‘CROP_RESIZE_WITH_MAX_POOL’: False, ‘CUDA’: False, ‘DATA_DIR’: ‘/home/marvin/Code/Pytorch/faster-rcnn.pytorch/data’, ‘DEDUP_BOXES’: 0.0625, ‘EPS’: 1e-14, ‘EXP_DIR’: ‘vgg16’, ‘FEAT_STRIDE’: [16], ‘GPU_ID’: 0, ‘MATLAB’: ‘matlab’, ‘MAX_NUM_GT_BOXES’: 20, ‘MOBILENET’: {‘DEPTH_MULTIPLIER’: 1.0, ‘FIXED_LAYERS’: 5, ‘REGU_DEPTH’: False, ‘WEIGHT_DECAY’: 4e-05}, ‘PIXEL_MEANS’: array([[[102.9801, 115.9465, 122.7717]]]), ‘POOLING_MODE’: ‘align’, ‘POOLING_SIZE’: 7, ‘RESNET’: {‘FIXED_BLOCKS’: 1, ‘MAX_POOL’: False}, ‘RNG_SEED’: 3, ‘ROOT_DIR’: ‘/home/marvin/Code/Pytorch/faster-rcnn.pytorch’, ‘TEST’: {‘BBOX_REG’: True, ‘HAS_RPN’: True, ‘MAX_SIZE’: 1000, ‘MODE’: ‘nms’, ‘NMS’: 0.3, ‘PROPOSAL_METHOD’: ‘gt’, ‘RPN_MIN_SIZE’: 16, ‘RPN_NMS_THRESH’: 0.7, ‘RPN_POST_NMS_TOP_N’: 300, ‘RPN_PRE_NMS_TOP_N’: 6000, ‘RPN_TOP_N’: 5000, ‘SCALES’: [600], ‘SVM’: False}, ‘TRAIN’: {‘ASPECT_GROUPING’: False, ‘BATCH_SIZE’: 256, ‘BBOX_INSIDE_WEIGHTS’: [1.0, 1.0, 1.0, 1.0], ‘BBOX_NORMALIZE_MEANS’: [0.0, 0.0, 0.0, 0.0], ‘BBOX_NORMALIZE_STDS’: [0.1, 0.1, 0.2, 0.2], ‘BBOX_NORMALIZE_TARGETS’: True, ‘BBOX_NORMALIZE_TARGETS_PRECOMPUTED’: True, ‘BBOX_REG’: True, ‘BBOX_THRESH’: 0.5, ‘BG_THRESH_HI’: 0.5, ‘BG_THRESH_LO’: 0.0, ‘BIAS_DECAY’: False, ‘BN_TRAIN’: False, ‘DISPLAY’: 10, ‘DOUBLE_BIAS’: True, ‘FG_FRACTION’: 0.25, ‘FG_THRESH’: 0.5, ‘GAMMA’: 0.1, ‘HAS_RPN’: True, ‘IMS_PER_BATCH’: 1, ‘LEARNING_RATE’: 0.01, ‘MAX_SIZE’: 1000, ‘MOMENTUM’: 0.9, ‘PROPOSAL_METHOD’: ‘gt’, ‘RPN_BATCHSIZE’: 256, ‘RPN_BBOX_INSIDE_WEIGHTS’: [1.0, 1.0, 1.0, 1.0], ‘RPN_CLOBBER_POSITIVES’: False, ‘RPN_FG_FRACTION’: 0.5, ‘RPN_MIN_SIZE’: 8, ‘RPN_NEGATIVE_OVERLAP’: 0.3, ‘RPN_NMS_THRESH’: 0.7, ‘RPN_POSITIVE_OVERLAP’: 0.7, ‘RPN_POSITIVE_WEIGHT’: -1.0, ‘RPN_POST_NMS_TOP_N’: 2000, ‘RPN_PRE_NMS_TOP_N’: 12000, ‘SCALES’: [600], ‘SNAPSHOT_ITERS’: 5000, ‘SNAPSHOT_KEPT’: 3, ‘SNAPSHOT_PREFIX’: ‘res101_faster_rcnn’, ‘STEPSIZE’: [30000], ‘SUMMARY_INTERVAL’: 180, ‘TRIM_HEIGHT’: 600, ‘TRIM_WIDTH’: 600, ‘TRUNCATED’: False, ‘USE_ALL_GT’: True, ‘USE_FLIPPED’: True, ‘USE_GT’: False, ‘WEIGHT_DECAY’: 0.0005}, ‘USE_GPU_NMS’: True} Loaded dataset voc_2007_trainval for training Set proposal method: gt Appending horizontally-flipped training examples… voc_2007_trainval gt roidb loaded from /home/marvin/Code/Pytorch/faster-rcnn.pytorch/data/cache/voc_2007_trainval_gt_roidb.pkl done Preparing training data… done before filtering, there are 10022 images… after filtering, there are 10022 images… 10022 roidb entries Loading pretrained weights from data/pretrained_model/vgg16_caffe.pth Traceback (most recent call last): File “trainval_net.py”, line 320, in <module> rois_label = fasterRCNN(im_data, im_info, gt_boxes, num_boxes) File “/home/marvin/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 477, in call result = self.forward(*input, **kwargs) File “/home/marvin/Code/Pytorch/faster-rcnn.pytorch/lib/model/faster_rcnn/faster_rcnn.py”, line 54, in forward roi_data = self.RCNN_proposal_target(rois, gt_boxes, num_boxes) File “/home/marvin/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 477, in call result = self.forward(*input, **kwargs) File “/home/marvin/Code/Pytorch/faster-rcnn.pytorch/lib/model/rpn/proposal_target_layer_cascade.py”, line 52, in forward rois_per_image, self._num_classes) File “/home/marvin/Code/Pytorch/faster-rcnn.pytorch/lib/model/rpn/proposal_target_layer_cascade.py”, line 133, in _sample_rois_pytorch labels = gt_boxes[:,:,4].contiguous().view(-1).index(offset.view(-1)).view(batch_size, -1) AttributeError: ‘Tensor’ object has no attribute ‘index’

Is there anyone know how to fix this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

27reactions
MathewXirencommented, Sep 23, 2018

fixed with the following code: labels = gt_boxes[:,:,4].contiguous().view(-1)[(offset.view(-1),)].view(batch_size, -1) Thanks @ahmed-shariff #289

0reactions
ahmed-shariffcommented, Nov 20, 2019

@charulatalodha have you looked at torchvisions models?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Tensor' object has no attribute 'shape' - Stack ...
I assume the first train_data.shape is a NumPy array. After you reassign the result of tf.reshape() to train_data its type is a tf.Tensor...
Read more >
AttributeError: 'Tensor' object has no attribute 'numpy'
I installed Tensorflow version 1.13.2 and It solved my error. 0. AttributeError: 'Tensor' object has no attribute 'get_shape'.
Read more >
Hi guys, how do I apply Faiss on torch.FloatTensor | Facebook
Hi guys, how do I apply Faiss on torch.FloatTensor? index.add(xb) is throwing an error "AttributeError: 'Tensor' object has no attribute 'flags' "
Read more >
'GradientBoostingRegressor' object has no attribute 'np'-numpy
Coding example for the question AttributeError: 'GradientBoostingRegressor' object has no attribute 'np'-numpy.
Read more >
'numpy.ndarray' object has no attribute 'seek' - You.com
'numpy.ndarray' object has no attribute 'index' is an attribute error which indicates that there is no index method or attribute available to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found