Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dice_ml/explainer_interfaces/dice_tensorflow1.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def do_cf_initializations(self, total_CFs, algorithm, features_to_vary):
def predict_fn(self, input_instance):
"""prediction function"""
temp_preds = self.dice_sess.run(self.output_tensor, feed_dict={self.input_tensor: input_instance})
return np.array([preds[(self.num_ouput_nodes-1):] for preds in temp_preds])
return np.array([preds[(self.num_output_nodes-1):] for preds in temp_preds])

def predict_fn_for_sparsity(self, input_instance):
"""prediction function for sparsity correction"""
Expand All @@ -239,22 +239,22 @@ def compute_yloss(self, method):
if method == "l2_loss":
temp_loss = tf.square(tf.subtract(
self.model.get_output(self.cfs_frozen[i]), self.target_cf))
temp_loss = temp_loss[:, (self.num_ouput_nodes-1):][0][0]
temp_loss = temp_loss[:, (self.num_output_nodes-1):][0][0]
elif method == "log_loss":
temp_logits = tf.log(
tf.divide(
tf.abs(tf.subtract(self.model.get_output(self.cfs_frozen[i]), 0.000001)),
tf.subtract(1.0, tf.abs(tf.subtract(self.model.get_output(
self.cfs_frozen[i]), 0.000001)))))
temp_logits = temp_logits[:, (self.num_ouput_nodes-1):]
temp_logits = temp_logits[:, (self.num_output_nodes-1):]
temp_loss = tf.nn.sigmoid_cross_entropy_with_logits(
logits=temp_logits, labels=self.target_cf)[0][0]
elif method == "hinge_loss":
temp_logits = tf.log(
tf.divide(
tf.abs(tf.subtract(self.model.get_output(self.cfs_frozen[i]), 0.000001)),
tf.subtract(1.0, tf.abs(tf.subtract(self.model.get_output(self.cfs_frozen[i]), 0.000001)))))
temp_logits = temp_logits[:, (self.num_ouput_nodes-1):]
temp_logits = temp_logits[:, (self.num_output_nodes-1):]
temp_loss = tf.losses.hinge_loss(
logits=temp_logits, labels=self.target_cf)

Expand Down