Skip to content

Commit 29ceab7

Browse files
committed
Minor changes.
1 parent 6a85dc6 commit 29ceab7

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

neural_structured_learning/research/gam/experiments/run_train_mnist.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
'max_num_iter_agr', 100000,
139139
'Maximum number of iterations to train the agreement model for.')
140140
flags.DEFINE_integer(
141-
'num_iter_after_best_val_agr', 5000,
141+
'num_iter_after_best_val_agr', 2000,
142142
'Minimum number of iterations to train the agreement model for after '
143143
'the best validation accuracy is improved.')
144144
flags.DEFINE_integer(
@@ -194,7 +194,7 @@
194194
flags.DEFINE_integer(
195195
'batch_size_cls', 512, 'Batch size for classification model.')
196196
flags.DEFINE_float(
197-
'gradient_clip', 10,
197+
'gradient_clip', None,
198198
'The gradient clipping global norm value. If None, no clipping is done.')
199199
flags.DEFINE_integer(
200200
'logging_step_cls', 200,
@@ -252,7 +252,7 @@
252252
'penalize_neg_agr', True,
253253
'Whether to encourage differences when agreement is negative.')
254254
flags.DEFINE_bool(
255-
'use_l2_cls', True,
255+
'use_l2_cls', False,
256256
'Whether to use L2 loss for the classifier, not cross entropy.')
257257
flags.DEFINE_bool(
258258
'first_iter_original', True,
@@ -424,10 +424,10 @@ def main(argv):
424424
# Put together parameters to create a model name.
425425
model_name = FLAGS.model_cls + (('_' + FLAGS.hidden_cls)
426426
if FLAGS.model_cls == 'mlp' else '')
427-
model_name += '-' + FLAGS.model_agr + (('_' + FLAGS.hidden_agr)
428-
if FLAGS.model_agr == 'mlp' else '')
429-
model_name += ('-aggr_' + FLAGS.aggregation_agr_inputs + '_' +
430-
FLAGS.hidden_aggreg)
427+
model_name += '-' + FLAGS.model_agr
428+
model_name += ('_' + FLAGS.hidden_agr) if FLAGS.model_agr == 'mlp' else ''
429+
model_name += '-aggr_' + FLAGS.aggregation_agr_inputs
430+
model_name += ('_' + FLAGS.hidden_aggreg) if FLAGS.hidden_aggreg else ''
431431
model_name += ('-add_%d-conf_%.2f-iter_cls_%d-iter_agr_%d-batch_cls_%d' %
432432
(FLAGS.num_samples_to_label, FLAGS.min_confidence_new_label,
433433
FLAGS.max_num_iter_cls, FLAGS.max_num_iter_agr,
@@ -436,7 +436,7 @@ def main(argv):
436436
model_name += '-perfectCls' if FLAGS.use_perfect_classifier else ''
437437
model_name += '-keepProp' if FLAGS.keep_label_proportions else ''
438438
model_name += '-PenNegAgr' if FLAGS.penalize_neg_agr else ''
439-
model_name += '-inductive' if FLAGS.inductive else ''
439+
model_name += '-transduct' if not FLAGS.inductive else ''
440440
model_name += '-L2Loss' if FLAGS.use_l2_cls else '-CELoss'
441441
model_name += '-seed_' + str(FLAGS.seed)
442442
model_name += FLAGS.experiment_suffix

neural_structured_learning/research/gam/models/cnn.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _construct_layers(self, inputs):
174174

175175
return local4, reg_params
176176

177-
def get_encoding_and_params(self, inputs, is_train, **kwargs):
177+
def get_encoding_and_params(self, inputs, **unused_kwargs):
178178
"""Creates the model hidden representations and prediction ops.
179179
180180
For this model, the hidden representation is the last layer
@@ -183,9 +183,7 @@ def get_encoding_and_params(self, inputs, is_train, **kwargs):
183183
Args:
184184
inputs: A tensor containing the model inputs. The first dimension is the
185185
batch size.
186-
is_train: A placeholder representing a boolean value that specifies if
187-
this model will be used for training or for test.
188-
**kwargs: Other keyword arguments.
186+
**unused_kwargs: Other unused keyword arguments.
189187
190188
Returns:
191189
encoding: A tensor containing an encoded batch of samples. The first
@@ -256,12 +254,10 @@ def get_predictions_and_params(self, encoding, is_train, **kwargs):
256254
shape=(input_size, self.output_dim),
257255
initializer=tf.truncated_normal_initializer(
258256
stddev=1.0/float(input_size),
259-
dtype=tf.float32),
260-
use_resource=True)
257+
dtype=tf.float32))
261258
biases = tf.get_variable(
262259
'b_outputs',
263-
initializer=tf.zeros([self.output_dim], dtype=tf.float32),
264-
use_resource=True)
260+
initializer=tf.zeros([self.output_dim], dtype=tf.float32))
265261
predictions = tf.add(tf.matmul(encoding, weights), biases,
266262
name='predictions')
267263

neural_structured_learning/research/gam/models/mlp.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _construct_layers(self, inputs):
9292
hidden = self.activation(tf.nn.xw_plus_b(hidden, weights, biases))
9393
return hidden, reg_params
9494

95-
def get_encoding_and_params(self, inputs, is_train, **kwargs):
95+
def get_encoding_and_params(self, inputs, **unused_kwargs):
9696
"""Creates the model hidden representations and prediction ops.
9797
9898
For this model, the hidden representation is the last layer of the MLP,
@@ -101,9 +101,7 @@ def get_encoding_and_params(self, inputs, is_train, **kwargs):
101101
Args:
102102
inputs: A tensor containing the model inputs. The first dimension is the
103103
batch size.
104-
is_train: A placeholder representing a boolean value that specifies if
105-
this model will be used for training or for test.
106-
**kwargs: Other keyword arguments.
104+
**unused_kwargs: Other unused keyword arguments.
107105
108106
Returns:
109107
encoding: A tensor containing an encoded batch of samples. The first

neural_structured_learning/research/gam/trainer/trainer_agreement.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,6 @@ def predict(self, session, src_features, tgt_features, **unused_kwargs):
754754
features of the first element of the pair.
755755
tgt_features: An array of shape (num_samples, num_features) containing the
756756
features of the second element of the pair.
757-
src_indices: An array of integers containing the index of each sample in
758-
self.data of the samples in src_features.
759-
tgt_indices: An array of integers containing the index of each sample in
760-
self.data of the samples in tgt_features.
761757
762758
Returns:
763759
An array containing the predicted agreement value for each pair of

0 commit comments

Comments
 (0)