def sparse_top_k_categorical_accuracy(y_true, y_pred, k=5): # If the shape of y_true is (num_samples, 1), squeeze to (num_samples,) if (len(K.int_shape(y_true)) == len(K.int_shape(y_pred))): y_true = array_ops.squeeze(y_true, [-1]) return K.mean(nn.in_top_k(y_pred, math_ops.cast(y_true, 'int32'), k), axis=-1)
def top_k_categorical_accuracy(y_true, y_pred, k=5): return K.mean( nn.in_top_k(y_pred, math_ops.argmax(y_true, axis=-1), k), axis=-1)
def _top_k(probabilities, targets): targets = math_ops.to_int32(targets) if targets.get_shape().ndims > 1: targets = array_ops.squeeze(targets, squeeze_dims=[1]) return metric_ops.streaming_mean(nn.in_top_k(probabilities, targets, k))
def sparse_top_k_categorical_accuracy(y_true, y_pred, k=5): return K.mean( nn.in_top_k(y_pred, math_ops.cast(math_ops.reduce_max(y_true, axis=-1), 'int32'), k), axis=-1)
def top_k_categorical_accuracy(y_true, y_pred, k=5): return K.mean(nn.in_top_k(y_pred, math_ops.argmax(y_true, axis=-1), k), axis=-1)
def sparse_top_k_categorical_accuracy(y_true, y_pred, k=5): return K.mean(nn.in_top_k( y_pred, math_ops.cast(math_ops.reduce_max(y_true, axis=-1), 'int32'), k), axis=-1)
def _top_k(probabilities, targets): return metric_ops.streaming_mean( nn.in_top_k(probabilities, math_ops.to_int32(targets), k))
def _top_k(probabilities, targets): targets = math_ops.cast(targets, dtypes.int32) if targets.get_shape().ndims > 1: targets = array_ops.squeeze(targets, axis=[1]) return metrics.mean(nn.in_top_k(probabilities, targets, k))
def _top_k(probabilities, targets): return metric_ops.streaming_mean(nn.in_top_k(probabilities, math_ops.to_int32(targets), k))
def model(a, b): return nn.in_top_k(a, b, topn)