gin-config icon indicating copy to clipboard operation
gin-config copied to clipboard

AttributeError: 'ModifiedTensorBoard' object has no attribute '_write_logs'

Open AdoniaMbarebaki opened this issue 4 years ago • 5 comments

C:\CarlaProject\PythonAPI\examples>python Adonia5.py Using TensorFlow backend. WARNING:tensorflow:From C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:88: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version. Instructions for updating: non-resource variables are not supported in the long term WARNING:tensorflow:From C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\ops\resource_variable_ops.py:1635: calling BaseResourceVariable.init (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version. Instructions for updating: If using Keras pass *_constraint arguments to layers. 2020-01-13 08:39:25.890943: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 Exception in thread Thread-2: Traceback (most recent call last): File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "Adonia5.py", line 278, in train_in_loop self.model.fit(X,y, verbose=False, batch_size=1) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\engine\training.py", line 1209, in fit if self._uses_dynamic_learning_phase(): File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\engine\training.py", line 382, in _uses_dynamic_learning_phase not isinstance(K.learning_phase(),int)) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 76, in symbolic_fn_wrapper if _SYMBOLIC_SCOPE.value: AttributeError: '_thread._local' object has no attribute 'value'

0%| | 0/100 [00:00<?, ?episodes/s]ERROR: failed to destroy actor 93 : time-out of 2000ms while waiting for the simulator, make sure the simulator is ready and connected to localhost:2000 ERROR: failed to destroy actor 94 : time-out of 2000ms while waiting for the simulator, make sure the simulator is ready and connected to localhost:2000 Traceback (most recent call last): File "Adonia5.py", line 379, in agent.tensorboard.update_stats(reward_avg=average_reward, reward_min=min_reward, reward_max=max_reward, epsilon=epsilon) File "Adonia5.py", line 102, in update_stats self._write_logs(stats, self.step) AttributeError: 'ModifiedTensorBoard' object has no attribute '_write_logs' What is the cause of such an error during reinforcement learning using Carla simulator?

AdoniaMbarebaki avatar Jan 13 '20 05:01 AdoniaMbarebaki

Did you manage to solve this error?

Cynamide avatar Apr 13 '20 11:04 Cynamide

you can check this link https://stackoverflow.com/questions/58711624/modifying-tensorboard-in-tensorflow-2-0

mina-parham avatar Apr 17 '20 04:04 mina-parham

@mina-parham the link is not working.

Any solution to this problem?

hrishavraj avatar May 01 '20 18:05 hrishavraj

@hrishavraj add this code in the ModifiedTensorBoard class

# Custom method for saving own metrics
# Creates writer, writes custom metrics and closes writer
def update_stats(self, **stats):
    self._write_logs(stats, self.step)

def _write_logs(self, logs, index):
    with self.writer.as_default():
        for name, value in logs.items():
            tf.summary.scalar(name, value, step=index)
            self.step += 1
            self.writer.flush()

britig avatar Jun 15 '20 12:06 britig

@hrishavraj add this code in the ModifiedTensorBoard class

# Custom method for saving own metrics
# Creates writer, writes custom metrics and closes writer
def update_stats(self, **stats):
    self._write_logs(stats, self.step)

def _write_logs(self, logs, index):
    with self.writer.as_default():
        for name, value in logs.items():
            tf.summary.scalar(name, value, step=index)
            self.step += 1
            self.writer.flush()

But my code is already like this

tangkg avatar Jan 18 '23 18:01 tangkg