Skip to content

Commit

Permalink
Migrate off of deprecated tf.contrib.distributions to supported tfp m…
Browse files Browse the repository at this point in the history
…ethod.

PiperOrigin-RevId: 272565264
  • Loading branch information
brianwa84 authored and copybara-github committed Oct 3, 2019
1 parent 36fed8b commit 8fc0416
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cnn_quantization/tf_cnn_benchmarks/convnet_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import numpy as np

import tensorflow as tf
import tensorflow_probability as tfp

from cnn_quantization.tf_cnn_benchmarks import mlperf
from tensorflow.contrib.quantize.python import common
from tensorflow.python.layers import convolutional as conv_layers
Expand Down Expand Up @@ -348,22 +350,22 @@ def last_value_quantize(self,

if per_channel:
if input_dim >= 2:
batch_min = tf.contrib.distributions.percentile(
batch_min = tfp.stats.percentile(
inputs, q=quantile, axis=reduce_dims, name='BatchMin')
else:
batch_min = inputs
else:
batch_min = tf.contrib.distributions.percentile(
batch_min = tfp.stats.percentile(
inputs, q=quantile, name='BatchMin')

if per_channel:
if input_dim >= 2:
batch_max = tf.contrib.distributions.percentile(
batch_max = tfp.stats.percentile(
inputs, q=100 - quantile, axis=reduce_dims, name='BatchMax')
else:
batch_max = inputs
else:
batch_max = tf.contrib.distributions.percentile(
batch_max = tfp.stats.percentile(
inputs, q=100 - quantile, name='BatchMax')

if narrow_range:
Expand Down

0 comments on commit 8fc0416

Please sign in to comment.