Questions tagged [computation-graph]

Use this tag for concepts and issues related to the computation graph in Chainer, PyTorch, Keras, TensorFlow, Theano and other Deep Learning frameworks.

A computational graph is a directed graph where the nodes correspond to operations or variables. Variables can feed their value into operations, and operations can feed their output into other operations. This way, every node in the graph defines a function of the variables.

24 questions
5
votes
1 answer

Why the grad is unavailable for the tensor in gpu

a = torch.nn.Parameter(torch.ones(5, 5)) a = a.cuda() print(a.requires_grad) b = a b = b - 2 print('a ', a) print('b ', b) loss = (b - 1).pow(2).sum() loss.backward() print(a.grad) print(b.grad) After executing codes, the a.grad is None although…
dddd
  • 53
  • 3
4
votes
0 answers

Seq2Seq Model (DL4J) Making Absurd Predictions

I am trying to implement a Seq2Seq Predictor Model in DL4J. What I ultimately want is to use a time series of INPUT_SIZE data points to predict the following time series of OUTPUT_SIZE data points using this type of model. Each data point has…
Alerra
  • 1,479
  • 11
  • 25
3
votes
0 answers

Can this nested for-loop be rewritten using tensorflow functions to allow for gradient calculation?

I wrote a function that sums only certain q-values from a tensor, those being the values corresponding to previous actions taken. I need this function to be auto-differentiable, but my current implementation uses a numpy array with nested for-loops,…
3
votes
0 answers

How to attach a tensor to a particular point in the computation graph in PyTorch?

As stated in the question, I need to attach a tensor to a particular point in the computation graph in Pytorch. What I'm trying to do is this: while geting outputs from all mini-batches, accumulate them in a list and when one epoch finishes,…
Aka
  • 137
  • 1
  • 12
2
votes
1 answer

How to create a 1-D range tensor when dimension is Unknown?

I have a n-D array. I need to create a 1-D range tensor based on dimensions. for an example: x = tf.placeholder(tf.float32, shape=[None,4]) r = tf.range(start=0, limit=, delta=x.shape[0],dtype=tf.int32, name='range') sess = tf.Session() result…
mariya
  • 117
  • 10
2
votes
0 answers

How to prepare dataset for a multi-task-learning network with a yolo output layer?

I have a convolutional neural network with a Yolo output-layer and multiple regression output-layers(I just mapped extra output layers to a typical Yolo CNN) using a computation graph. The problem I have is with the dataset, for the Yolo output I…
linker
  • 821
  • 1
  • 8
  • 20
2
votes
1 answer

How Weight update in Dynamic Computation Graph of pytorch works?

How does the Weight Update works in Pytorch code of Dynamic Computation Graph when Weights are shard (=reused multiple times) https://pytorch.org/tutorials/beginner/examples_nn/dynamic_net.html#sphx-glr-beginner-examples-nn-dynamic-net-py import…
user423491
  • 73
  • 1
  • 8
1
vote
0 answers

Get C/C++/Latex code from Jaxpr or Jax XLA Computation Object

I am making a procedurally generated terrain for which I used the Classic Perlin Noise give here. Now to calculate the normal to the terrain I need the differential of this function, so I rewrote the function in python and used jax.grad to…
1
vote
2 answers

Find PyTorch model parameters that don't contribute to loss

In PyTorch (v1.10) Distibuted DataParallel, unused parameters in a model that don't contribute to the final loss can raise a RuntimeError (as mentioned in this other question, this PyTorch forums thread). "RuntimeError: Expected to have finished…
dingus
  • 655
  • 1
  • 7
  • 18
1
vote
1 answer

How can I get the associated tensor from a Torch FX Graph Node?

I want to be able to get all the operations that occur within a torch module, along with how they are parameterized. To do this, I first made a torch.fx.Tracer that disables leaf nodes so that I can get the graph without call_modules: class…
iHowell
  • 2,263
  • 1
  • 25
  • 49
1
vote
1 answer

How does Pytorch build the computation graph

Here is example pytorch code from the website: class Net(nn.Module): def __init__(self): super(Net, self).__init__() # 1 input image channel, 6 output channels, 3x3 square convolution # kernel self.conv1 = nn.Conv2d(1, 6, 3) …
chessprogrammer
  • 768
  • 4
  • 15
1
vote
0 answers

How to implement tree structured lstm as a recursive neural network in tensorflow?

I was developing a tre_lstm for my sentiment analysis model and finally, I ran to an error which was about the various shape of input data. As each input text might have a different binary tree structure (and different number of lstm cells), the…
ramin karimian
  • 113
  • 2
  • 9
1
vote
0 answers

Performance drawback of tf.numpy_function?

I'm using a tf.numpy_function to load a file in my tensorflow program. I can't find sufficient information about the drawbacks of using numpy_function, would there be enough that it's worth the trouble of passing this function to tensorflow…
Papotitu
  • 407
  • 1
  • 4
  • 16
1
vote
1 answer

Tensorflow tf.placeholder with shape = []

I am looking at a Tensorflow code that has learning rate input to the graph using placeholder with shape = [], as below: self.lr_placeholder = tf.placeholder(dtype=tf.float32, shape=[]) I looked at the official documentation page of Tensorflow…
1
vote
0 answers

How can I replace a variable with another one in Tensorflow's computation graph?

Problem: I have two pretrained models with variables W1,b1 and W2,b2 saved as numpy arrays. I want to set a mixture of these two pretrained models as the variables of my model, and only update the mixture weights alpha1 and alpha2 during…
Ash
  • 3,428
  • 1
  • 34
  • 44
1
2