Professional Documents
Culture Documents
tf.disable_v2_behavior()
print(tf.version.VERSION)
frames = 41
bands = 20
2.0.0
def one_hot_encode(labels):
n_labels = len(labels)
n_unique_labels = len(np.unique(labels))
one_hot_encode = np.zeros((n_labels, n_unique_labels))
one_hot_encode[np.arange(n_labels), labels] = 1
return one_hot_encode
In [19]: tf.reset_default_graph()
batch_size = 50
display_step = 200
# Network Parameters
n_input = bands
n_steps = frames
n_hidden = 320
n_classes = 10
learning_rate = 0.01
training_iterations = 4000
# Evaluate model
correct_pred = tf.equal(tf.argmax(prediction,1), tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
/home/juansta/anaconda3/lib/python3.7/site-packages/tensorflow_core/python/framework/indexed
_slices.py:424: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown sh
ape. This may consume a large amount of memory.
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
if epoch % display_step == 0:
# Calculate batch accuracy
acc = session.run(accuracy, feed_dict={x: batch_x, y: batch_y})
# Calculate batch loss
loss = session.run(loss_f, feed_dict={x: batch_x, y: batch_y})
print("Iter " + str(epoch) + ", Minibatch Loss= " + \
"{:.6f}".format(loss) + ", Training Accuracy= " + \
"{:.5f}".format(acc))
In [ ]: