首页 > 解决方案 > 用于不规则张量占位符的 R Keras 功能 API 方法?

问题描述

在 python 中,我可以实例化一个参差不齐的张量占位符,如下所示。

inputs_1 = keras.Input(shape=[None,], dtype='int64', ragged=True, name = 'message_A')
inputs_1
tf.RaggedTensor(values=Tensor("Placeholder:0", shape=(None,), dtype=int64), row_splits=Tensor("Placeholder_1:0", shape=(None,), dtype=int64))

Tensorflow responds that the placeholder is ragged with a shape=(None,).  But using R-Keras & R-Tensorflow its seems I cannot do the same.  I can request an input placeholder and the parameter to make it ragged exists but the response suggests it is not in fact ragged.  Additionally, you are forced to declare some shape rather than keep the shape 'flexible' for the ragged tensor.  

inputs_1 = tf$keras$Input(shape=c(100L), ragged = TRUE)
inputs_1
Tensor("Placeholder:0", shape=(None, 100), dtype=float32)

你能告诉我如何使用 R-Keras 或 R-Tensorflow 创建一个参差不齐的张量占位符吗?

标签: pythonrtensorflowkeras

解决方案


推荐阅读