tensorflow2.0

Tensorflow: How to prefetch data on the GPU from CPU tf.data.Dataset (from_generator)

你说的曾经没有我的故事 提交于 2021-02-07 10:15:38
问题 I am struggling with the following. I am creating a tf.data.Dataset using the from_generator method. I perform these actions on CPU as I don't want to overload my GPU memory. The dataset consists of tuples, which contain a tf.bool 1-D mask (tf.Tensor) with fixed length, and a tf.float 2-D matrix (tf.Tensor) with variable size. The loss function is decorated using the following decorator, so I would not assume the variable size is the problem. @tf.function(experimental_relax_shapes=True)

Modifying TensorBoard in TensorFlow 2.0

旧时模样 提交于 2021-02-07 03:32:55
问题 I'm following Sentdex's DQN tutorial. I'm stuck trying to rewrite custom TensorBoard in TF 2.0. The point is to add **stats to a file, for example: {'reward_avg': -99.0, 'reward_min': -200, 'reward_max': 2, 'epsilon': 1} Original code: class ModifiedTensorBoard(TensorBoard): def __init__(self, **kwargs): super().__init__(**kwargs) self.step = 1 self.writer = tf.summary.FileWriter(self.log_dir) # Custom method for saving own metrics # Creates writer, writes custom metrics and closes writer def

Modifying TensorBoard in TensorFlow 2.0

♀尐吖头ヾ 提交于 2021-02-07 03:32:38
问题 I'm following Sentdex's DQN tutorial. I'm stuck trying to rewrite custom TensorBoard in TF 2.0. The point is to add **stats to a file, for example: {'reward_avg': -99.0, 'reward_min': -200, 'reward_max': 2, 'epsilon': 1} Original code: class ModifiedTensorBoard(TensorBoard): def __init__(self, **kwargs): super().__init__(**kwargs) self.step = 1 self.writer = tf.summary.FileWriter(self.log_dir) # Custom method for saving own metrics # Creates writer, writes custom metrics and closes writer def

Modifying TensorBoard in TensorFlow 2.0

人走茶凉 提交于 2021-02-07 03:31:48
问题 I'm following Sentdex's DQN tutorial. I'm stuck trying to rewrite custom TensorBoard in TF 2.0. The point is to add **stats to a file, for example: {'reward_avg': -99.0, 'reward_min': -200, 'reward_max': 2, 'epsilon': 1} Original code: class ModifiedTensorBoard(TensorBoard): def __init__(self, **kwargs): super().__init__(**kwargs) self.step = 1 self.writer = tf.summary.FileWriter(self.log_dir) # Custom method for saving own metrics # Creates writer, writes custom metrics and closes writer def

Use TensorBoard with Keras Tuner

醉酒当歌 提交于 2021-02-06 09:21:46
问题 I ran into an apparent circular dependency trying to use log data for TensorBoard during a hyper-parameter search done with Keras Tuner, for a model built with TF2. The typical setup for the latter needs to set up the Tensorboard callback in the tuner's search() method, which wraps the model's fit() method. from kerastuner.tuners import RandomSearch tuner = RandomSearch(build_model, #this method builds the model hyperparameters=hp, objective='val_accuracy') tuner.search(x=train_x, y=train_y,

Use TensorBoard with Keras Tuner

旧街凉风 提交于 2021-02-06 09:21:36
问题 I ran into an apparent circular dependency trying to use log data for TensorBoard during a hyper-parameter search done with Keras Tuner, for a model built with TF2. The typical setup for the latter needs to set up the Tensorboard callback in the tuner's search() method, which wraps the model's fit() method. from kerastuner.tuners import RandomSearch tuner = RandomSearch(build_model, #this method builds the model hyperparameters=hp, objective='val_accuracy') tuner.search(x=train_x, y=train_y,

How to solve tensor flow cpu dll not found error

岁酱吖の 提交于 2021-02-01 05:12:39
问题 I have install tensorflow v2.1.0 with python version 3.6.6 and pip version 20.0.2 . When i try to import tensorflow i got below error. C:\Users\Dexter>python Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow Traceback (most recent call last): File "C:\Users\Dexter\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\pywrap

How to solve tensor flow cpu dll not found error

风流意气都作罢 提交于 2021-02-01 05:08:59
问题 I have install tensorflow v2.1.0 with python version 3.6.6 and pip version 20.0.2 . When i try to import tensorflow i got below error. C:\Users\Dexter>python Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow Traceback (most recent call last): File "C:\Users\Dexter\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\pywrap

how to Split data in 3 folds (train,validation,test) using ImageDataGenerator when data is in different directories of each class

China☆狼群 提交于 2021-01-29 17:34:53
问题 How do I split my data into 3 folds using ImageDataGenerator of Keras? ImageDataGenerator only gives validation_split argument so if I use it, I wont be having my test set for later purpose. My data is in the form of >input_data_dir >class_1_dir > image_1.png > image_2.png > class_2_dir > class_3_dir 回答1: As you rightly mentioned, splitting the Data into 3 Folds is not possible in one line of code using Keras ImageDataGenerator . Work around would be to store the Images corresponding to Test

Custom max_pool layer: ValueError: The channel dimension of the inputs should be defined. Found `None`

a 夏天 提交于 2021-01-29 17:26:50
问题 I am working on tensorflow2 and I am trying to implement Max unpool with indices to implement SegNet. When I run it I get the following problem. I am defining the def MaxUnpool2D and then calling it in the model. I suppose that the problem is given by the fact that updates and mask have got shape (None, H,W,ch). def MaxUnpooling2D(updates, mask): size = 2 mask = tf.cast(mask, 'int32') input_shape = tf.shape(updates, out_type='int32') # calculation new shape output_shape = ( input_shape[0],