Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor[slice].assign() not working #653

Closed
Banyc opened this issue Dec 4, 2020 · 0 comments
Closed

Tensor[slice].assign() not working #653

Banyc opened this issue Dec 4, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Banyc
Copy link
Member

Banyc commented Dec 4, 2020

Issue

When running the code below:

Tensor x = tf.Variable(tf.ones((2, 2)));
Console.WriteLine(x);

// https://stackoverflow.com/a/43139565/9920172
x["0", "0"].assign(tf.constant(2));
Console.WriteLine(x);
Tensor y = x["0", "0"].assign(tf.constant(2));
Console.WriteLine(y);

An error occurs:

An unhandled exception of type 'System.ArgumentException' occurred in TensorFlow.NET.dll: 'Dimensions { and { are not compatible'

In Addition

This operation is mentioned in Tensorflow official documentation. Here is the link: https://www.tensorflow.org/api_docs/python/tf/Variable#__getitem__.

import tensorflow as tf
A = tf.Variable([[1,2,3], [4,5,6], [7,8,9]], dtype=tf.float32)
with tf.compat.v1.Session() as sess:
  sess.run(tf.compat.v1.global_variables_initializer())
  print(sess.run(A[:2, :2]))  # => [[1,2], [4,5]]

  op = A[:2,:2].assign(22. * tf.ones((2, 2)))
  print(sess.run(op))  # => [[22, 22, 3], [22, 22, 6], [7,8,9]]
Banyc added a commit to Banyc/TensorFlow.NET that referenced this issue Dec 4, 2020
The test case is currently not passed yet.
Oceania2018 pushed a commit that referenced this issue Dec 5, 2020
The test case is currently not passed yet.
@Oceania2018 Oceania2018 added the bug Something isn't working label Dec 5, 2020
Oceania2018 added a commit that referenced this issue Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants