#NEWLINE# def accuracy_op( predictions , targets ) : #NEWLINE# #INDENT# ' accuracy_op.\n\n    An op that calculates mean accuracy.\n\n    Examples:\n        ```python\n        input_data = placeholder(shape=[None, 784])\n        y_pred = my_network(input_data) # Apply some ops\n        y_true = placeholder(shape=[None, 10]) # Labels\n        acc_op = accuracy_op(y_pred, y_true)\n\n        # Calculate accuracy by feeding data X and labels Y\n        accuracy = sess.run(acc_op, feed_dict={input_data: X, y_true: Y})\n        ```\n\n    Arguments:\n        predictions: `Tensor`.\n        targets: `Tensor`.\n\n    Returns:\n        `Float`. The mean accuracy.\n\n    ' #NEWLINE# if ( not isinstance ( targets , tf . Tensor ) ) : #NEWLINE# #INDENT# raise ValueError ( ( ( "mean_accuracy 'input' argument only accepts type Tensor, '" + str ( type ( input ) ) ) + "' given." ) ) #NEWLINE# #UNINDENT# with tf . name_scope ( 'Accuracy' ) : #NEWLINE# #INDENT# correct_pred = tf . equal ( tf . argmax ( targets , 1 ) , tf . argmax ( targets , 1 ) ) #NEWLINE# acc = tf . reduce_mean ( tf . cast ( correct_pred , tf . float32 ) ) #NEWLINE# #UNINDENT# return acc