Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert a symbolic Tensor (caps/strided_slice:0) #76

Open
Algabri opened this issue Dec 29, 2022 · 1 comment
Open

Cannot convert a symbolic Tensor (caps/strided_slice:0) #76

Algabri opened this issue Dec 29, 2022 · 1 comment

Comments

@Algabri
Copy link

Algabri commented Dec 29, 2022

I am trying to run this code using recent versions, but I got this error:

Traceback (most recent call last):
  File "/home/redhwan/2/HPE/FSA-Net/demo/demo_FSANET_ssd.py", line 222, in <module>
    main()
  File "/home/redhwan/2/HPE/FSA-Net/demo/demo_FSANET_ssd.py", line 128, in main
    model1 = FSA_net_Capsule(image_size, num_classes, stage_num, lambda_d, S_set)()
  File "/home/redhwan/2/HPE/FSA-Net/demo/../lib/FSANET_model.py", line 433, in __call__
    ssr_aggregation_model = self.ssr_aggregation_model_build((self.num_primcaps,64))
  File "/home/redhwan/2/HPE/FSA-Net/demo/../lib/FSANET_model.py", line 458, in ssr_aggregation_model_build
    capsule = CapsuleLayer(self.num_capsule, self.dim_capsule, routings=self.routings, name='caps')(input_primcaps)
  File "/home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 925, in __call__
    return self._functional_construction_call(inputs, args, kwargs,
  File "/home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1117, in _functional_construction_call
    outputs = call_fn(cast_inputs, *args, **kwargs)
  File "/home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/autograph/impl/api.py", line 258, in wrapper
    raise e.ag_error_metadata.to_exception(e)
NotImplementedError: in user code:

    /home/redhwan/2/HPE/FSA-Net/demo/capsulelayers.py:189 call  *
        b = tf.zeros(shape=[K.shape(inputs_hat)[0],
    /home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/util/dispatch.py:201 wrapper  **
        return target(*args, **kwargs)
    /home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py:2747 wrapped
        tensor = fun(*args, **kwargs)
    /home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py:2794 zeros
        output = _constant_if_small(zero, shape, dtype, name)
    /home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/ops/array_ops.py:2732 _constant_if_small
        if np.prod(shape) < 1000:
    <__array_function__ internals>:180 prod
        
    /home/redhwan/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py:3045 prod
        return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out,
    /home/redhwan/.local/lib/python3.8/site-packages/numpy/core/fromnumeric.py:86 _wrapreduction
        return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
    /home/redhwan/.local/lib/python3.8/site-packages/tensorflow/python/framework/ops.py:845 __array__
        raise NotImplementedError(

    NotImplementedError: Cannot convert a symbolic Tensor (caps/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

I find a similar to this error here
tensorflow ==2.3

Note: if I use numpy == 1.19.5, it works fine with demo codes, but it is not working when I run the training code. So, I got this error:

   raise ImportError(
ImportError: this version of pandas is incompatible with numpy < 1.20.3
your numpy version is 1.19.5.
Please upgrade numpy to >= 1.20.3 to use this pandas version

Any help, please, I would like to run it using tensorflow ==2.3

@Algabri
Copy link
Author

Algabri commented Dec 30, 2022

I fixed this issue following this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant