Suggested Change to Advanced Tutorials, tf$ones arguments

Open
#528 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
48/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
r, tensorflow
Domain
documentation

Research direction

Open the Advanced Tutorials section on R array compatibility at the linked tensors and operations page and compare the current tf$ones example with the reported error. Update the tutorial example to the working syntax shown in the issue, then verify that it produces the expected TensorFlow output.

Written by the indexing model from the issue text.

Description

Hi Team,

I have been continuing my journey through the tutorials, and have come across an issue in the advanced tutorials, r array compatibility
.

It appears that the syntax currently in the tutorials used for the tf$ones operation seems to be outdated and needs to be updated to 1+tf$ones(shape(1)).

The current code and error output I get is:

> # TensorFlow operations convert arrays to Tensors automatically
> 1 + tf$ones(shape = 1)
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  TypeError: Cannot convert 1.0 to EagerTensor of dtype int32

Detailed traceback:
  File "C:\PROGRA~3\ANACON~1\envs\R-RETI~1\lib\site-packages\tensorflow\python\util\traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\PROGRA~3\ANACON~1\envs\R-RETI~1\lib\site-packages\tensorflow\python\framework\constant_op.py", line 102, in convert_to_eager_tensor
    return ops.EagerTensor(value, ctx.device_name, dtype)

However, by adjusting the code from an example snippet from here, line 15 & 16 I get the correct output

> 1+tf$ones(shape(1))
tf.Tensor([2.], shape=(1), dtype=float32)
Dominant language
R
Stars
1.3k
Forks
316
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/tensorflow

All issues in rstudio/tensorflow

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.