Yes I think this is known:

  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      Calling model.test_on_batch after model.evaluate returns corrupted values for the loss and the metrics 13
    

    
      
        opened 
        
          
        
        Feb 23, 2021
      
      


      
        
          
          ogrisel
        
      
    

    
        stat:awaiting tensorflower
        type:bug
        comp:keras
        TF 2.4
    
  


  
    **System information**
- Google colab with tf 2.4.1 (v2.4.1-0-g85c8b2a817f )
-… with CPU or GPU runtimes, it does not matter

**Describe the current behavior**

Calling `model.test_on_batch` after calling `model.evaluate` gives incorrect results.

**Describe the expected behavior**

Calling `model.test_on_batch` should  return the a value that does not depend on whether`model.evaluate`  was called before.

**Standalone code to reproduce the issue**

Let's define a randomly initialized model evaluated on randomly generated data. If we call `model.test_on_batch` directly, everything is fine:

```python
import numpy as np
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

rng = np.random.RandomState(0)
batch_size = 32
n_samples, n_features = batch_size * 10, 5
X = rng.normal(size=(n_samples, n_features))
y = rng.randint(low=0, high=2, size=X.shape[0])

model = Sequential([Dense(1, input_shape=(n_features,),
                          activation="sigmoid")])
model.compile(optimizer="adam", loss='binary_crossentropy',
              metrics=['accuracy'])

print("model.test_on_batch without model.evaluate")
for i in range(3):
    loss, acc = model.test_on_batch(X[:batch_size], y[:batch_size])
    print(loss, acc)
```

output:

```
model.test_on_batch without model.evaluate
6.294709205627441 0.5625
6.294709205627441 0.5625
6.294709205627441 0.5625
```

If we then call `evaluate`, the fist call of `model.test_on_batch` return an incorrect value:

```python
normal_loss, normal_acc = model.evaluate(
    X, y, batch_size=batch_size, verbose=0)

print("model.test_on_batch *after* model.evaluate")
for i in range(3):
    loss, acc = model.test_on_batch(X[:batch_size], y[:batch_size])
    print(loss, acc)
```

output:

```
model.test_on_batch *after* model.evaluate
6.585799694061279 0.4801136255264282
6.294709205627441 0.5625
6.294709205627441 0.5625
```

Note: this is a minimal reproducer of the report found in the comments of a similar standalone keras issue: https://github.com/keras-team/keras/issues/14086

It is probably also the cause or at least related to corrupted loss/metric values reported when using `evaluate_generator`:
https://github.com/keras-team/keras/issues/13780