Categories
Mastering Development

Tensorflow with batch size and wrong dimesion

Here are my code: # Model parameters: W and b # tf.reset_default_graph() W = tf.get_variable("weight",shape = [784, 10], dtype=tf.float32) b = tf.get_variable("b", shape=(784,10), dtype= tf.float32) input_X = tf.placeholder(‘float32’, shape = (None,10)) input_y = tf.placeholder(‘float32’, [784, 10]) ogits = W*input_X + b probas = tf.nn.softmax(logits) classes = tf.argmax(probas) loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels = input_y, logits = logits)) […]

Categories
Artificial Intelligence (AI) Mastering Development

How to access the numerical value of loss and accuracy over the training epoch of a neural network?

history = model.fit(X_train, Y_train,batch_size=32 ,epochs=300, validation_data = (X_test, Y_test), verbose=2) pd.DataFrame(history.history).plot(figsize=(8, 5)) plt.grid(True) plt.gca().set_ylim(0, 1) plt.show() I use the following code (Keras + Tensorflow) to plot my neural network model performance over each training epoch as However,Is there anyway to access the data of these 4 performance metric that is loss , accuracy, val_loss, val_accuracy […]

Categories
Mastering Development

I followed the tensorflow image segmentation tutorial, but the predicted mask is blank

I’d like to try image segmentation with my grayscale tif images (the shape of original images are (512,512) and the value of each pixel is between 0-2 or nan which is in float32 type and the mask images have 0, 1, or nan also in float32 type). I followed Google Colab and tensorflow tutorialto create […]

Categories
Development

How to write the values of a dictionary into a CSV file

This is my Python version: import sys print(sys.version) >> 3.6.9 (default, Nov 7 2019, 10:44:02) >> [GCC 8.3.0] And I’m running on a Google Colaboratory notebook. I’m newbie with Python and I haven’t found any useful example to show me how to write the following dictionary to a CSV. print(my_dict) >> {‘loss’: [0.411, 0.115, 0.147, […]

Categories
Development

Keras – UnboundLocalError: local variable ‘batch_index’ referenced before assignment

I have created my deep neural network model based on LSTM using Keras on Tensorflow backend. When I call thefit function of my model, getting the UnboundLocalError: local variable ‘batch_index’ referenced before assignment. I have tried the answers provided to a similar question, but they did not work for me. Some others recommended to downgrade […]

Categories
Development

Issues with KeyError: ‘val_acc’

This is rather a popular error, but I couldn’t find a proper answer given my setup. I found this tutorial code, but when running, I get this error: val_acc = history.history[‘val_acc’] KeyError: ‘val_acc’ The fit_generator() function unlike fit(), doesn’t allow a validation split. So how to fix it? Here is the code: def plot_training(history): print […]