# Tag: tensor

## How to use tf.repeat() to replicate a specific column/row/slice?

this thread explains well the use of tf.repeat() as a tensorflow alternative to np.repeat(). one functionality which I was unable to figure out, in np.repeat(), a specific column/row/slice can be replicated by supplying the index. e.g. is there any tensorflow alternative to this functionality of np.repeat()? Answer You could use the repeats parameter of tf.repeat: where you get the first

## shape of an output tensor after convolutional filter on a colour image

I find it difficult to understand a notion about tensors. For VGG (https://www.tensorflow.org/api_docs/python/tf/keras/applications/VGG16), we start from a batch of colour images (none,224,224,3) and …

## Training MaskRCNN on custom data issue

I am trying to train Mask RCNN on a custom dataset of floorplans. I am following this article on Medium to do this: https://medium.com/analytics-vidhya/a-simple-guide-to-maskrcnn-custom-dataset-…

## Convert 5D tensor to 4D tensor in PyTorch

In PyTorch I have a 5D tensor X of dimensions B x 9 x C x H x W. I want to convert it into a 4D tensor Y with dimensions B x 9C x H x W such that concatenation happens channel wise. To illustrate let, …

## How to get the last index of model’s prediction?

I am new to PyTorch. I have a variable pred which has a list of a tensor. print(pred) output: [tensor([[176.64380, 193.86154, 273.84702, 306.30405, 0.83492, 2.00000]])] So I wanted to access the last …

## How to append rank 1 tensors using only tensorflow operations?

Say I have two rank 1 tensors of different (important) length: import tensorflow as tf x = tf.constant([1, 2, 3]) y = tf.constant([4, 5]) Now I want to append y to the end of x to give me the tensor: …

## How to convert a PyTorch sparse_coo_tensor into a PyTorch dense tensor?

I create a sparse_coo tensor in PyTorch: import torch # create indices i = torch.tensor([[0, 1, 1], [2, 0, 2]]) # create values v = torch.tensor([3, 4, 5], dtype=torch.float32) # …

## How does the “view” method work in PyTorch?

I am confused about the method view() in the following code snippet. class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(3, 6, 5) …