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
0 votes
0 answers
30 views

Pytorch LSTM model with multiple features

I am working on a Pytorch LSTM model that is able to detect patterns in sequence of N variables that leads to a good outcome vs bad outcome. The code is below. I tested it with a test case and it was ...
0 votes
0 answers
35 views

MNIST classifier and autoencoder: 2 in 1 deal

I built an autoencoder with a latent space of dimension 10 that doubles as a classifier (the predicted digit is the argmax of the latent space). This was obtained by optimizing both the digit ...
  • 27.3k
1 vote
0 answers
73 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 ...
0 votes
1 answer
95 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: ...
  • 3
2 votes
1 answer
68 views

Loss function in python is a bit cumbersome

This is my first post here. I seek to improve my way of writing Python and C++ code. I hope I can also contribute to others when I have increased my skill. Here is a python function I have for a ...
  • 169
1 vote
0 answers
45 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. ...
  • 11
1 vote
0 answers
67 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 ...
7 votes
1 answer
113 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 ...
2 votes
0 answers
134 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 ...
  • 265
3 votes
1 answer
127 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 ...
  • 265
2 votes
0 answers
23 views

Enhancing performance using DataParallel

I have written the following code to practice parallelizing a PyTorch code on GPUs: ...
  • 265
3 votes
0 answers
61 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 ...
1 vote
1 answer
2k views

Loops in PyTorch Implementation

I'm trying to implement a regularization term for the loss function of a neural network. ...
  • 265
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 ...
  • 73
2 votes
0 answers
104 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? ...
4 votes
1 answer
2k 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,...
  • 141
1 vote
0 answers
28 views

Splitting torch tensor by flags

Working with PyTorch tensors, I need to split the batch of items by its flags, so the items in x_batch_one and x_batch_two are ...
1 vote
0 answers
110 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 ...
20 votes
2 answers
11k 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 ...
  • 21.7k