Closed m273033 closed 6 years ago
Do other methods work? Could you post (or mail me) a minimal code example where this problem occurs?
I have sent you an email with the code. I am basically trying to get this to work on a text-cnn network.
The most common cause of ValueError("None values not supported.")
is that run()
is called with a tensor_input
and target_tensor
that are disconnected in the backpropagation. For example, this is common when an embedding lookup is used. The lookup does not propagate the gradient. To generate attribution of NLP models the input for DeepExplain should be the embedding itself instead of the original model input. Then the attributions of each word are found by summing up along the appropriate dimension in the attribution result.
Here a minimal example in Tensorflow:
input_x = graph.get_operation_by_name("input_x").outputs[0]
# Get reference to the embedding tensor
embedding = graph.get_operation_by_name("embedding").outputs[0]
pre_softmax = graph.get_operation_by_name("output/scores").outputs[0]
# Evaluate the embedding tensor on the model input (in other words, perform the lookup)
embedding_out = sess.run(embedding, {input_x: x_test})
# Run DeepExplain with the embedding as input
attributions = de.explain('elrp', pre_softmax * y_test_logits, embedding, embedding_out)
Close as the problem seems to have been solved.
DeepExplain: running "elrp" explanation method (4) Traceback (most recent call last): File "./train.py", line 193, in
attributions = de.explain('elrp', cnn.scores, cnn.input_x, x_test)
File "/home/../tensorflow/src/deepexplain/deepexplain/tensorflow/methods.py", line 414, in explain
result = method.run()
File "/home/../tensorflow/src/deepexplain/deepexplain/tensorflow/methods.py", line 91, in run
attributions = self.get_symbolic_attribution()
File "/home/../tensorflow/src/deepexplain/deepexplain/tensorflow/methods.py", line 205, in get_symbolic_attribution
return tf.gradients(self.T, self.X)[0] * self.X
File "/home/../tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 909, in r_binary_op_wrapper
x = ops.convert_to_tensor(x, dtype=y.dtype.base_dtype, name="x")
File "/home/../tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 836, in convert_to_tensor
as_ref=False)
File "/home/../tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/../tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 229, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/home/../tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 208, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/home/../tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 371, in make_tensor_proto
raise ValueError("None values not supported.")
ValueError: None values not supported.
I am constantly getting this error. I tried using DeepExplain before/after training, I also checked the input sizes and shapes. I am giving (method name,a layer above softmax * one hot label, input tensor, test data) as parameters. I don't know maybe I am missing out something or what. Please help me with resolving this error