Category "tensor"

Lookup table in TensorFlow with key is string and value is list of strings

I would like to generate a Lookup table in TensorFlow with key is string and value is list of strings. But it seems currently no classes in tf.lookup support th

Assigning custom weights to embedding layer in PyTorch

Does PyTorch's nn.Embedding support manually setting the embedding weights for only specific values? I know I could set the weights of the entire embedding laye

Sort Tensorflow HashTable by value

My Code : h_table = tf.lookup.StaticHashTable( initializer=tf.lookup.KeyValueTensorInitializer( keys=[0, 1, 2, 3, 4, 5], values=[12.3,

How to mask a 3D tensor with 2D mask and keep the dimensions of original vector?

Suppose, I have a 3D tensor A A = torch.arange(24).view(4, 3, 2) print(A) and require masking it using 2D tensor mask = torch.zeros((4, 3), dtype=torch.int6

Efficient pooling operation in Tensorflow : Custom pooling layer

I wish to create a custom pooling layer which can efficiently work on GPUs. For instance, I have following input tensor in = <tf.Tensor: shape=(4, 5), dtype=

TensorFlow: How do I generate a dataset from two arrays?

I've been trying to generate a custom dataset from two arrays. One with the shape (128,128,6) (satellite data with 6 channels), and the other with the shape (12

Visualize Tensor [1,64,112,112] using matplotlib

I have a output tensor after convolution of dimensions [1,64,112,112]. Is there any way I can visualize this using matplotlib only, keeping in mind that imshow(

CUDA error: device-side assert triggered on Colab

I am trying to initialize a tensor on Google Colab with GPU enabled. device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') t = torch.tensor([1,

How to extract tensors to numpy arrays or lists from a larger pytorch tensor

I have a list of pytorch tensors as shown below: data = [[tensor([0, 0, 0]), tensor([1, 2, 3])], [tensor([0, 0, 0]), tensor([4, 5, 6])]] Now this is ju

PyTorch torch.max over multiple dimensions

Have tensor like :x.shape = [3, 2, 2]. import torch x = torch.tensor([ [[-0.3000, -0.2926],[-0.2705, -0.2632]], [[-0.1821, -0.1747],[-0.1526, -0.1453]

tensorflow 2 TextVectorization process tensor and dataset error

I would like to process text with tensorflow 2.8 on Jupyter notebook. my code: import re import string import tensorflow as tf from tensorflow import keras from

sliding window on a tensor

I'm trying to build a simple word generator. However, I encounter some difficulty with the sliding windows. here is my actual code: files = glob("transfdata/*")

Padding a tensor until reaching required size

I'm working with certian tensors with shape of (X,42) while X can be in a range between 50 to 70. I want to pad each tensor that I get until it reaches a size o

How to resize a PyTorch tensor?

I have a PyTorch tensor of size (5, 1, 44, 44) (batch, channel, height, width), and I want to 'resize' it to (5, 1, 224, 224) How can I do that? What functions

numpy equivalent code of unsqueeze and expand from torch tensor method

I have these 2 tensors box_a = torch.randn(1,4) box_b = torch.randn(1,4) and i have a code in pytorch box_a[:, 2:].unsqueeze(1).expand(1, 1, 2) but i want to

Merge one tensor into other tensor on specific indexes in PyTorch

Any efficient way to merge one tensor to another in Pytorch, but on specific indexes. Here is my full problem. I have a list of indexes of a tensor in below cod