TypeError:过度执行不支持形状的tf.constant

时间:2019-04-26 13:29:33

标签: tensorflow-probability

我正在尝试从“ Probabilistic_Layers_Regression.ipynb”中修改8的input_shape和8的output_shape的代码。我从下面的示例代码中得到以下错误。有什么想法吗?谢谢 - - 错误 - - - TypeError跟踪(最近一次通话) 在()

11 dtype=x.dtype)[..., np.newaxis]),
12 unconstrained_observation_noise_variance_initializer=(
---> 13 tf.constant_initializer(np.array(0.54).astype(x.dtype))),
14 ),
15 ])

TypeError:急于执行不支持形状的tf.constant(值包含40个元素,形状为(1、40、8),带有320个元素)

在tfp.layers.VariationalGaussianProcess上找不到太多文档

num_inducing_points = 40
model = tf.keras.Sequential([
       tf.keras.layers.InputLayer(input_shape=[8], dtype=x.dtype), 
       tf.keras.layers.Dense(8, kernel_initializer='ones',            use_bias=False),
       tfp.layers.VariationalGaussianProcess(
          enter code herenum_inducing_points=num_inducing_points,
          kernel_provider=RBFKernelFn(dtype=x.dtype),
          event_shape=[1], #x.shape[1]],
       inducing_index_points_initializer=tf.constant_initializer(
          np.linspace(*x_range, num=num_inducing_points,
          dtype=x.dtype)[..., np.newaxis]),
       unconstrained_observation_noise_variance_initializer=(
          tf.constant_initializer(np.array(0.54).astype(x.dtype))),
 ),
])

由8个元素组成的数组,而不是1个用于输出

0 个答案:

没有答案
相关问题