tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.44k stars 1.92k forks source link

print values of tf or tf.backend() failed on API page #7370

Open axinging opened 1 year ago

axinging commented 1 year ago

In the API page(https://js.tensorflow.org/api/latest), when try console.log(tf), it complains:

An error occured on line: 3
Converting circular structure to JSON
    --> starting at object with constructor 'Window'
    --- property 'window' closes the circle

when try console.log(tf.backend()), it complains

An error occured on line: 3
Converting circular structure to JSON
    --> starting at object with constructor 't'
    |     property 'texData' -> object with constructor 'e'
    --- property 'backend' closes the circle

Also I noticed that below APIs doesn't have test code in the API page, is this intended behaviour? tf.backend tf.getBackend tf.ready tf.registerBackend tf.removeBackend tf.setBackend

If tf.backend() is not supported in the API page, then the two cases mentioned in https://github.com/tensorflow/tfjs/issues/7289 may possibly fail to run.

pyu10055 commented 1 year ago

@axinging There is a circular reference in the backend object, which on the tensor/texData map (pointing back to the backend object), which is causing the error for console log. But the methods related to backend are on the tfjs-core engine object, I don't think the other errors you mentioned are related to the console.log issue.

gaikwadrahul8 commented 1 year ago

Hi, @axinging

Apologize for the delayed response and I tried to replicate the same issue from my end with latest version of @tensorflow/tfjs@4.10.0 and still I'm getting the same error messages which you mentioned above with console.log()for your reference I have added screenshot below. please refer above comment from @pyu10055

Above mentioned APIs don't have test code in the API page. Thank you!

CC :@pyu10055

image