You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for i, ridx in enumerate(test_sample_paths):
x = dset[ridx]['matrix']
x = x.reshape((1, -1, 300,1))
x = x.numpy()
prob = k_model.predict_on_batch(x)[0]
y_hat = prob.argmax()
for aidx, analyzer in enumerate(analyzers):
a = np.squeeze(analyzer.analyze(x))
a = np.sum(a, axis=1) ### Add the values along the embedding dimension
analysis[i, aidx] = a
This code results in error in this line a = np.squeeze(analyzer.analyze(x)) (This is for Smoothgrad analyzer) . The error is given below. When I rerun the cell, I get the same error again(This is for integrated_gradient analyzer), but on 3rd time, it runs FINE!! The print the text heatmap later and they seem to be alright as well.
TypeError Traceback (most recent call last)
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
526 try:
--> 527 str_values = [compat.as_bytes(x) for x in proto_values]
528 except TypeError:
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in (.0)
526 try:
--> 527 str_values = [compat.as_bytes(x) for x in proto_values]
528 except TypeError:
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/util/compat.py in as_bytes(bytes_or_text, encoding)
60 raise TypeError('Expected binary or unicode string, got %r' %
---> 61 (bytes_or_text,))
62
TypeError: Expected binary or unicode string, got -1
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in
18 for aidx, analyzer in enumerate(analyzers):
19 print(analyzer)
---> 20 a = np.squeeze(analyzer.analyze(x))#, neuron_selection=y_hat))
21 print(a.shape)
22 a = np.sum(a, axis=1) ### Add the values along the embedding dimension
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/innvestigate/analyzer/wrapper.py in analyze(self, X, *args, **kwargs)
143 if self._keras_based_augment_reduce is True:
144 if not hasattr(self._subanalyzer, "_analyzer_model"):
--> 145 self.create_analyzer_model()
146
147 ns_mode = self._neuron_selection_mode
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in reshape(x, shape)
1967 A tensor.
1968 """
-> 1969 return tf.reshape(x, shape)
1970
1971
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py in reshape(tensor, shape, name)
6480 if _ctx is None or not _ctx._eager_context.is_eager:
6481 _, _, _op = _op_def_lib._apply_op_helper(
-> 6482 "Reshape", tensor=tensor, shape=shape, name=name)
6483 _result = _op.outputs[:]
6484 _inputs_flat = _op.inputs
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
511 except TypeError as err:
512 if dtype is None:
--> 513 raise err
514 else:
515 raise TypeError(
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
508 dtype=dtype,
509 as_ref=input_arg.is_ref,
--> 510 preferred_dtype=default_dtype)
511 except TypeError as err:
512 if dtype is None:
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx)
1144
1145 if ret is None:
-> 1146 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
1147
1148 if ret is NotImplemented:
~/anaconda3/envs/gpu_ptorch/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
529 raise TypeError("Failed to convert object of type %s to Tensor. "
530 "Contents: %s. Consider casting elements to a "
--> 531 "supported type." % (type(values), values))
532 tensor_proto.string_val.extend(str_values)
533 return tensor_proto
TypeError: Failed to convert object of type <class 'tuple'> to Tensor. Contents: (-1, 64, None, 300, 1). Consider casting elements to a supported type.
I am running this code cell in a notebook
This code results in error in this line
a = np.squeeze(analyzer.analyze(x))
(This is for Smoothgrad analyzer) . The error is given below. When I rerun the cell, I get the same error again(This is for integrated_gradient analyzer), but on 3rd time, it runs FINE!! The print the text heatmap later and they seem to be alright as well.The analyzers are the following:
There is no error in this code cell
The text was updated successfully, but these errors were encountered: