<p>Just like changing a single pixel in an image doesn't change the image, changing one bit in an array doesn't significantly adjust the prediction.</p>
<p>I ran mobilenet on a black 224x224 image and it predicted class 819 (whatever that is).  Then I changed the top-left pixel to white and re-ran mobilenet and it still classifies as class 819.</p>
<p><a href="https://www.tensorplayground.com/1.0.0/?code=//+TensorPlayground.com%0A//+RGB+Tensor%0A//+INPUT+TENSOR+SHAPE:+%5B622,1024,3%5D%0A//+MODEL:+Mobilenet+v2+Expects+%5Bbatch,+224,+224,+3%5D%0A%0A(tf,+aTensor,+model)+%3D%3E+%7B%0A++//+Black+Box%0A++const+blackBox+%3D+tf.zeros(%5B224,+224,+3%5D)%0A++const+blackBatch+%3D+blackBox.expandDims(0)%0A++const+result1+%3D+model.predict(blackBatch)%0A++console.log(%27predicted+from+zeros%27,+tf.topk(result1,+1).indices.dataSync())%0A++%0A++//+Black+box+with+a+dot%0A++const+arrayRep+%3D+blackBatch.arraySync()%0A++arrayRep%5B0%5D%5B0%5D%5B0%5D+%3D+%5B1,+1,+1%5D%0A++const+singleDotBox+%3D+tf.tensor4d(arrayRep)%0A++const+result2+%3D+model.predict(singleDotBox)%0A++console.log(%27predicted+from+zeros%27,+tf.topk(result1,+1).indices.dataSync())%0A++%0A++return+singleDotBox%0A%7D&amp;inputTensor=bella&amp;modelInfo=%7B%22value%22:%22mobilenetv2%22,%22label%22:%22Mobilenet+v2%22,%22info%22:%22Expects+%5Bbatch,+224,+224,+3%5D%22,%22link%22:%22https://arxiv.org/abs/1801.04381%22,%22url%22:%22https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2%22,%22fromTFHub%22:true,%22type%22:%22graph%22%7D" rel="nofollow noreferrer">See example code here</a></p>
<p>Changing a single bit does not have a cascading effect like a hash function.  Mobilenet, by its nature is resilient to noise.</p>
why does model.predict in tensorflowjs keeps returning the same incorrect output regardless of the tensor given?
<p>I'm trying to get a keras model i converted to tensorflow js, to work in react native but the model keeps giving bad responses. Did some digging and found realized that the tensor i passed into model.predict is some how being changed causing it to give the same incorrect prediction. Any suggestions would be appreciated. I'm pretty much hard stuck. Code below:</p>
<pre><code>import React, {useState, useEffect} from 'react';
import {View, Text, Button} from 'react-native';
import * as tf from '@tensorflow/tfjs';
import {
  bundleResourceIO
} from '@tensorflow/tfjs-react-native';
import * as mobilenet from '@tensorflow-models/mobilenet';

function thing() {
  const [model, setModel] = useState(null);
  const [tensor, setTensor] = useState(null); 
  
  async function loadModel() {
    const modelJson = require('./assets/model.json');
    const weight = require('./assets/group1-shard1of1.bin');
    const backend = await tf.ready();
    const item = await tf.loadLayersModel(
        bundleResourceIO(modelJson, weight)
    );
    const tfTensor = tf.tensor([[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]);
    
    setModel(item);
    setTensor(tfTensor);
  }

  useEffect(() =&gt; {
    loadModel();
  }, []);

  async function test() {
    if(tensor !== null &amp;&amp; model !== null) {
      const result = await model.predict(tensor);
      console.log(result.dataSync())
    }
  }

  return (
    &lt;View&gt;
      &lt;Button
        onPress={test}
        title=&quot;click&quot;
        color=&quot;#841584&quot;
        accessibilityLabel=&quot;Learn more about this purple button&quot;
      /&gt;

    &lt;/View&gt;
  );
}

export default thing;


</code></pre>