Skip to main content

Questions tagged [pytorch]

PyTorch is a deep learning framework that implements a dynamic computational graph, which allows you to change the way your neural network behaves on the fly and capable of performing backward automatic differentiation.

Filter by
Sorted by
Tagged with
4 votes
1 answer
137 views

String art program in Python using PyTorch

...
flakpm's user avatar
  • 97
3 votes
1 answer
86 views

Pytorch code running slow for Deep Q learning (Reinforcement Learning)

I'm a new student in reinforcement learning. Below is the code that I wrote for deep Q learning: ...
Jahid Chowdhury Choton's user avatar
2 votes
1 answer
40 views

One-layer linear neural network to solve a regression problem in PyTorch

Good morning everyone, I am trying to figure out how deep learning works. My approach is mainly theoretical but I have decided to code a few deep learning projects to get a better feel of the kind of ...
francescoriccardocrescenzi's user avatar
1 vote
0 answers
63 views

Convolution to reduce popcorn noise in black and white video

I have a black & white video as a tensor with the shape [Time, Width, Height] with popcorn noise and I would like to reduce the noise by naively convolving along the time dimension. Using a ...
Seanny123's user avatar
  • 1,527
0 votes
0 answers
22 views

Efficiently computing a batch of results given a batch assignment vector and series of corresponding matrices

I have a 1D tensor of tokens that belong to different batches. The batch sizes here are uneven. Each batch needs to be multiplied with a corresponding weight matrix. My current approach is using a ...
sidnb13's user avatar
3 votes
1 answer
91 views

Randomly rotate an image through right angles

I'm new to Python, and coming from Typescript, I tried to include types, but it's not obvious sometimes. Currently this is the way I type objects: Write own simple types Import type from a library ...
user avatar
0 votes
0 answers
53 views

Exctracting features from each frame of a video and stacking all the frames' features at the end

I am working with videos. So, the input of my model has the shape of [batch_size,channels,frames,height,width]. So, my goal is to extract the the features from each frame separately using ResNet2D and ...
dtr43's user avatar
  • 51
1 vote
0 answers
106 views

Storing multiple PyTorch tensors of different shapes with names that are not known by advance

I need to create a container for instances of torch.Tensor of different shapes, where I can call them by their name. It is a use case for a dict except that: I don't want to rely on the heavy syntax ...
Xiiryo's user avatar
  • 111
2 votes
0 answers
84 views

neural network that determines the gender of a word

I wrote a neural network in python using pytorch, which determines the gender of a word in Russian. As a training set: a file containing a word and a number from 0 to 2 (0-masculine,1- feminine and 2-...
user avatar
2 votes
0 answers
94 views

Higher order derivatives with functorch

I'm computing higher order derivatives using nested jacobian from pytorch/functorch. $$f(x, y, z, \dots) : R^{m_x} \times R^{m_y}...
I.M.'s user avatar
  • 121
1 vote
0 answers
158 views

Binary classification with pytorch

I wrote a simple neural network binary classification algorithm using Pytorch. It uses the dataset from https://www.kaggle.com/pritsheta/heart-attack, which consists of a table with 300 rows and 14 ...
user3053216's user avatar
1 vote
1 answer
635 views

Set min value of each row of a tensor to zero without using explicit loops

Here's the problem. Return a copy of x, where the minimum value along each row has been set to 0. For example, if x is: ...
Ryan's user avatar
  • 13
2 votes
1 answer
100 views

Loss function in python is a bit cumbersome

Here is a python function I have for a neural network I have implemented. I feel it become a bit cumbersome. The intention is to weight positive labels in channels ...
El_Loco's user avatar
  • 169
1 vote
0 answers
54 views

resnet with pytorch

I was studying resnet and wanted to program it with pytorch I searched for some examples(github, google) but it was hard to understand the code completely So I programmed resnet myself and it works. ...
JayK's user avatar
  • 11
1 vote
0 answers
82 views

Complex division for imaginary part

I seek a fast implementation of (x / y).imag, where x, y are complex 2D arrays (PyTorch tensors already on GPU). My approach is ...
OverLordGoldDragon's user avatar
7 votes
1 answer
114 views

A .py utility file for neural network learing rate policies

I've created a .py utility file, which specifies the learning rate policy for the neural network in PyTorch. The program in prior reads a ...
spiridon_the_sun_rotator's user avatar
2 votes
0 answers
271 views

Computing inverse of modified matrix using Sherman-Morrison formula

I have the following implementation that takes in symmetric matrix W and returns matrix C ...
Blade's user avatar
  • 285
4 votes
1 answer
295 views

increase efficiency of loops and element-wise operations in PyTorch implementation

For any input symmetric matrix with zero diagonals W, I have the following implementation in PyTorch. I was wondering if the ...
Blade's user avatar
  • 285
2 votes
0 answers
26 views

Enhancing performance using DataParallel

I have written the following code to practice parallelizing a PyTorch code on GPUs: ...
Blade's user avatar
  • 285
3 votes
0 answers
65 views

Batch normalization code optimization?

I am trying to implement Deep Quaternion Networks. I was able to implement the batch normalization technique. But it requires a lot of GPU memory. Is there any way I can optimize the code provided ...
Shreyas Kamath's user avatar
2 votes
1 answer
2k views

Loops in PyTorch Implementation

I'm trying to implement a regularization term for the loss function of a neural network. ...
Blade's user avatar
  • 285
4 votes
2 answers
1k views

PyTorch Vectorized Implementation for Thresholding and Computing Jaccard Index

I have been trying to optimize a code snippet which finds the optimal threshold value in a n_patch * 256 * 256 probability map to get the highest Jaccard index ...
yiping's user avatar
  • 73
2 votes
0 answers
141 views

GRU-Autoencoder training

I'm training a GRU auto-encoder and my current code is very slow.I believe it's predict_captions function that takes most the time. Any suggestion to optimize this code? ...
Marzi Heidari's user avatar
5 votes
1 answer
3k views

PyTorch Unit-testing in Python

I'm new to PyTorch and I'm writing a unit test for an activation function I'm making. I plan to test against a reference implementation for this function. I want to approach this in a test-driven way,...
lynn's user avatar
  • 153
1 vote
0 answers
120 views

Posterior collapses in an RNN variational auto-encoder - PyTorch

I am trying to implement and train an RNN variational auto-encoder as the one explained in "Generating Sentences from a Continuous Space". Although I apply their proposed techniques to mitigate ...
abdullah.cu's user avatar
20 votes
2 answers
13k views

Intersection over Union for rotated rectangles

Problem Statement I am trying to find the intersection over union (IoU) metric for one to several rotated rectangles compared to many different rotated rectangles. Here are some images to help ...
syb0rg's user avatar
  • 21.8k