def load(self, session, model_path): x_input = tf.placeholder(self.x_dtype, shape=(None, ) + self.x_shape) with slim.arg_scope(inception_v3.inception_v3_arg_scope()): inception_v3.inception_v3(x_input, num_classes=self.n_class, is_training=False, reuse=tf.AUTO_REUSE) saver = tf.train.Saver(slim.get_model_variables(scope='InceptionV3')) saver.restore(session, model_path)
def _logits_and_labels(self, xs_ph): xs_ph = xs_ph * 2.0 - 1.0 batch_size = tf.shape(xs_ph)[0] xs_tile = tf.tile(tf.expand_dims(xs_ph, 1), [1, self.num_ensemble, 1, 1, 1]) xs_tile = tf.reshape(xs_tile, (-1, ) + self.x_shape) with slim.arg_scope(inception_v3.inception_v3_arg_scope()): with tf.variable_scope('RandDisc'): xs_tile = iterative_clustering_layer( source=xs_tile, n_clusters=self.n_clusters, sigma=10, alpha=10, noise_level_1=self.noise_level, noise_level_2=self.noise_level) logits, _ = inception_v3.inception_v3(xs_tile, num_classes=self.n_class, is_training=False, reuse=True) logits = tf.reshape(logits, [batch_size, self.num_ensemble, -1]) logits = tf.reduce_mean(logits, axis=1) labels = tf.cast(tf.argmax(logits, 1), tf.int32) return logits, labels
def _logits_and_labels(self, xs_ph): xs_ph = xs_ph * 2.0 - 1.0 with slim.arg_scope(inception_v3.inception_v3_arg_scope()): logits, end_points = inception_v3.inception_v3( xs_ph, num_classes=self.n_class, is_training=False, reuse=tf.AUTO_REUSE) predicted_labels = tf.argmax(end_points['Predictions'], 1) return logits, predicted_labels