What is this Discretization function exactly? If its implemented in numpy, you cannot use it within a keras layer, as gradients cannot be propagated through it. Also consider that the function has to be differentiable too.
On Monday, 29 November 2021 17:29:46 CET ALI Q SAEED wrote:
| Hi there,
| i am trying to Discretization every feature map generated by a conv layer,
| however Discretization function expected float values for boundaries not
| tensors. based on that, when i use .numpy() to extract the values of
| tensors(which are scalars) to be fed as float values to the boundaries args
| i get the following error:
|
| *AttributeError: 'KerasTensor' object has no attribute 'numpy'*
|
| and if i feed the scalar directly to the Discretization function without
| using .numpy(), i get the following error :
|
| *TypeError: Expected float for argument 'boundaries' not <KerasTensor:
| shape=() dtype=float32 (created by layer 'tf.math.divide_8')>.*
| *My questions :*
| *1. is there any possibility to use .numpy inside custom function called by
| lambda layer?*
| *2. is it possible to use **Discretization func. in such away? if not, is
| it possible to mimic its functionality using tf ops?*
Good, the Discretize layer does not support bin boundaries to be symbolic tensors, they need to be fixed floating point values, better make them a hyper-parameter, not a value that depends on the data.
On Monday, 29 November 2021 21:20:42 CET ALI Q SAEED wrote:
| Thanks for your reply.
| Discretization is a preprocessing layer which buckets continuous features
| by ranges (reference
| <https://www.tensorflow.org/api_docs/python/tf/keras/layers/Discretization>)
| . it accepts any tf.Tensor
| <https://www.tensorflow.org/api_docs/python/tf/Tensor> or tf.RaggedTensor
| <https://www.tensorflow.org/api_docs/python/tf/RaggedTensor> of dimension 2
PENAFIAN: E-mel ini dan apa-apa fail yang dikepilkan bersamanya ("Mesej") adalah ditujukan hanya untuk kegunaan penerima(-penerima) yang termaklum di atas dan mungkin mengandungi maklumat sulit. Anda dengan ini dimaklumkan bahawa mengambil apa jua tindakan bersandarkan kepada, membuat penilaian, mengulang hantar, menghebah, mengedar, mencetak, atau menyalin Mesej ini atau sebahagian daripadanya oleh sesiapa selain daripada penerima(-penerima) yang termaklum di atas adalah dilarang. Jika anda telah menerima Mesej ini kerana kesilapan, anda mesti menghapuskan Mesej ini dengan segera dan memaklumkan kepada penghantar Mesej ini menerusi balasan e-mel. Pendapat, rumusan, dan sebarang maklumat lain di dalam Mesej ini yang tidak berkait dengan urusan rasmi Universiti Kebangsaan Malaysia (UKM) adalah difahami sebagai bukan dikeluar atau diperakui oleh mana-mana pihak yang disebut.
DISCLAIMER : This e-mail and any files transmitted with it ("Message") is intended only for the use of the recipient(s) named above and may contain confidential information. You are hereby notified that the taking of any action in reliance upon, or any review, retransmission, dissemination, distribution, printing or copying of this Message or any part thereof by anyone other than the intended recipient(s) is strictly prohibited. If you have received this Message in error, you should delete this Message immediately and advise the sender by return e-mail. Opinions, conclusions and other information in this Message that do not relate to the official business of The National University of Malaysia (UKM) shall be understood as neither given nor endorsed by any of the aforementioned.
--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/759d2951-2515-406b-a2d5-2d7ce0f6dc86n%40googlegroups.com.