Computer Vision News - June 2018
Now let’s move to tfdbg which is a specialized debugger for TensorFlow . It lets you monitor the structure, weights and parameters of TensorFlow graphs. To work with tfdbg, you must include the following lines in your code: In the following example, we’ll see how to use tfdbg to monitor whether there are any nan or inf values anywhere in the network. The code below demonstrates how to register a simple filter named tfdbg.has_inf_or_nan to determine if there are any nan or inf values in any intermediate tensor of the graph: After running your network (with the above code), you will be prompted with the tfdbg, then can use “ run -f has_inf_or_nan ” which executes the training procedure until any tensor contains nan or inf which triggers that filter and stops the training execution process. Finally, after the network has successfully been trained and achieved a low loss, we would like now to try, analyze and understand what the network has actually 15 Tool Computer Vision News tbCallBack = Keras.callbacks.TensorBoard( log_dir = './Graph' , histogram_freq = True , write_graph = True , write_images = True ) # TrueCompile the model model.compile( loss = 'categorical_crossentropy' , optimizer =optimizers.RMSprop( lr = 1e-4 ), metrics =[ 'acc' ]) model.fit(x_train, y_train, batch_size =batch_size, epochs =epochs, validation_data =(x_test, y_test), shuffle = True , callbacks =[tbCallBack]) from TensorFlow.python import debug as tf_debugsess = tf_debug.LocalCLIDebugWrapperSession(sess) sess.add_tensor_filter('has_inf_or_nan', tf_debug.has_inf_or_nan) for Deep Learning in TensorFlow and Keras
Made with FlippingBook
RkJQdWJsaXNoZXIy NTc3NzU=