tensorflow error with in processing algorithm, adversarial debiasing, which is based on tf

19 Views Asked by At

I am using adversarial debiasing model from AIF360 which uses TensorFlow. I am getting an error : ValueError: Variable debiased_classifier_20710/classifier_model/W1 already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? I am not sure how to handle this error as I am not using TensorFlow directly in my code, I just imported the TensorFlow as base for the model to work. Any leads can be helpful.

Below is the part of code and error I encountered:
sess = tf.Session()
debiased_model = AdversarialDebiasing(privileged_groups = privileged_groups, unprivileged_groups = unprivileged_groups, scope_name = f'debiased_classifier_{int(np.random.random()*100000)}', debias = True, sess = sess)
model = debiased_model.fit(train_df)
File "python3.10/site-packages/aif360/algorithms/transformer.py", line 27, in wrapper
new_dataset = func(self, *args, **kwargs)
File "python3.10/site-packages/aif360/algorithms/inprocessing/adversarial_debiasing.py", line 152, in fit
self.pred_labels, pred_logits = self._classifier_model(self.features_ph, self.features_dim, self.keep_prob)
File "python3.10/site-packages/aif360/algorithms/inprocessing/adversarial_debiasing.py", line 84, in _classifier_model
W1 = tf.get_variable('W1', [features_dim, self.classifier_num_hidden_units],
File "python3.10/site-packages/tensorflow/python/ops/variable_scope.py", line 1616, in get_variable
return get_variable_scope().get_variable(
File "python3.10/site-packages/tensorflow/python/ops/variable_scope.py", line 1326, in get_variable
return var_store.get_variable(
File "python3.10/site-packages/tensorflow/python/ops/variable_scope.py", line 582, in get_variable
return _true_getter(
File "python3.10/site-packages/tensorflow/python/ops/variable_scope.py", line 535, in _true_getter
return self._get_single_variable(
File "python3.10/site-packages/tensorflow/python/ops/variable_scope.py", line 891, in _get_single_variable
raise ValueError(err_msg)
ValueError: Variable debiased_classifier_20710/classifier_model/W1 already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope?

I tried researching the ways I can handle this but none of the ways shows to handle this error when TensorFlow is being used at backend by a model.

0

There are 0 best solutions below