tensor

How do I return just one element from this output?

How do I return just one element from this output? Question: I am using TensorFlow in Python. When making a prediction with my model, here is my input: UberLyft_model.predict(my_UberLyft_encoded) I get this output: 1/1 [==============================] – 0s 53ms/step array([[16.11945]], dtype=float32) But I simply want this output: 16.11945 Asked By: Swifty || Source Answers: Try prediction …

Total answers: 1

PyTorch: bitwise OR all elements below a certain dimension

PyTorch: bitwise OR all elements below a certain dimension Question: New to pytorch and tensors in general, I could use some guidance 🙂 I’ll do my best to write a correct question, but I may use terms incorrectly here and there. Feel free to correct all of this 🙂 Say I have a tensor of …

Total answers: 2

Is there a difference between torch.IntTensor and torch.Tensor

Is there a difference between torch.IntTensor and torch.Tensor Question: When using PyTorch tensors, is there a point to initialize my data like so: X_tensor: torch.IntTensor = torch.IntTensor(X) Y_tensor: torch.IntTensor = torch.IntTensor(Y) Or should I just do the ‘standard’: X_tensor: torch.Tensor = torch.Tensor(X) Y_tensor: torch.Tensor = torch.Tensor(Y) even though I know X: list[list[int] and Y: list[list[int] …

Total answers: 2

Image search on Marqo is returning random results – how can I fix this?

Image search on Marqo is returning random results – how can I fix this? Question: I configured a marqo index for image search as follows: settings = { "treat_urls_and_pointers_as_images":True, # allows us to find an image file and index it "model":"ViT-L/14" } response = mq.create_index("my-multimodal-index", **settings) I then added some documents: mq.index("my-multimodal-index").add_documents( [ {"image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSBgKtI0_GMZMd1Zm4UGRO4E5RL5bN9kBO0FA&usqp=CAU", …

Total answers: 1

Keeping the dimensions when using torch.diff on a tensor in pytorch

Keeping the dimensions when using torch.diff on a tensor in pytorch Question: Suppose the following code: a=torch.rand(size=(3,3,3), dtype=torch.float32) a_diff=torch.diff(a, n=1, dim= 1, prepend=None, append=None).shape print(a_diff) torch.Size([3, 2, 3]) I would like to keep the dimensions like the original a with (3,3,3). How can I append 0 to the beginning of the sequence so that the dimensions …

Total answers: 1

How to make an empty tensor in Pytorch?

How to make an empty tensor in Pytorch? Question: In python, we can make an empty list easily by doing a = []. I want to do a similar thing but with Pytorch tensors. If you want to know why I need that, I want to get all of the data inside a given dataloader …

Total answers: 1

Selective meshgrid in Tensorflow

Selective meshgrid in Tensorflow Question: Given the following code: import tensorflow as tf def combine(x, y): xx, yy = tf.meshgrid(x, y, indexing=’ij’) combo = tf.stack([tf.reshape(xx, [-1]), tf.reshape(yy, [-1])], axis=1) print(combo) x = tf.constant([11, 0, 7, 1]) combine(x, x) I want to clean combo vector in order to obtain the following tf vector [(11, 0), (11, …

Total answers: 1

FashionMNIST Dataset not transforming to Tensor

FashionMNIST Dataset not transforming to Tensor Question: Trying to calculate the mean and standard deviation of the dataset to normalise it afterwards. Current Code: train_dataset = datasets.FashionMNIST(‘data’, train=True, download = True, transform=[transforms.ToTensor()]) test_dataset = datasets.FashionMNIST(‘data’, train=False, download = True, transform=[transforms.ToTensor()]) def calc_torch_mean_std(tens): mean = torch.mean(tens, dim=1) std = torch.sqrt(torch.mean((tens – mean[:, None]) ** 2, dim=1)) …

Total answers: 1