# Is it safe to call SameDiff.evaluate during training phase

**URL:** <https://community.konduit.ai/t/is-it-safe-to-call-samediff-evaluate-during-training-phase/1895>\
**Category:** SameDiff\
**Created:** [June 6, 2022, 4:21am UTC](https://community.konduit.ai/t/is-it-safe-to-call-samediff-evaluate-during-training-phase/1895 "2022-06-06T04:21:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![valb3r](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/valb3r/32/754_2.png) [@valb3r](https://community.konduit.ai/u/valb3r)\
**Post date:** [June 6, 2022, 4:21am UTC](https://community.konduit.ai/t/is-it-safe-to-call-samediff-evaluate-during-training-phase/1895/1 "2022-06-06T04:21:14Z")

</div>

I’ve noticed that `SameDiff.output`/`SameDiff.fit` (training phase) and `SameDiff.evaluate` modify internal SameDiff state quite a bit. JavaDoc does not specify is it safe to call `SameDiff.evaluate` when performing `SameDiff.fit` (I need something like data preprocessor that runs directly within SameDiff evaluation rather than as preprocessor inside BaseDatasetIterator).

As I’ve found several implementation options, here are the questions I have regarding each of option:

1. Is it safe to execute `SameDiff.evaluate` inside custom `DifferentialFunction` while executing `SameDiff.fit`? Or it is safer to use `SameDiff.invokeGraphOn` on some copy instead
2. Is it safe to execute `SameDiff.evaluate` inside custom training listener that **will modify network inputs** while executing `SameDiff.fit`? Or it is safer to use `SameDiff.invokeGraphOn` on some copy instead
