Skip to content

TypeError: u[1].flatten is not a function #7721

@kungfooman

Description

@kungfooman

System information

  • OS Platform and Distribution: Linux Mint / Chrome + Firefox
  • TensorFlow.js version: tf.version_core == "4.6.0"
  • Browser version: Version 113.0.5672.126 (Offizieller Build) (64-Bit)

Describe the current behavior

Code crashes with: Uncaught (in promise) TypeError: u[1].flatten is not a function:

image

Describe the expected behavior

Code does not crash, it should work like in node.

Standalone code to reproduce the issue

testFlattenBug.html

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-layers"></script>
<script>
  tf.setBackend('webgl').then(testBug);
  function testBug() {
    const numEncoderTokens = 49;
    const latentDim = 256;
    const encoderInputs = tf.layers.input({
      shape: [null, numEncoderTokens] /*as number[]*/,
      name: 'encoderInputs',
    });
    const encoder = tf.layers.lstm({
      units: latentDim,
      returnState: true,
      name: 'encoderLstm',
    });
    const [, stateH, stateC] = encoder.apply(encoderInputs) /*as tf.SymbolicTensor[]*/;
  }
</script>

Other info / logs

I converted simply this example to run in the browser:

https://github.com/tensorflow/tfjs-examples/blob/6d5986a6c73f62753f2253e263214ac02706445f/translation/translation.ts#L215-L226

It works in node itself, but why would it fail in the browser with such a JS bug?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions