小编sea*_*ran的帖子

预期 min_ndim=2,发现 ndim=1。收到完整形状:(无,)

在我的模型中,我有一个用于 1 列特征数组的归一化层。我假设这给出了 1 ndim 输出:

single_feature_model = keras.models.Sequential([
    single_feature_normalizer,
    layers.Dense(1)
])
Run Code Online (Sandbox Code Playgroud)

正常化步骤:

single_feature_normalizer = preprocessing.Normalization(axis=None)
single_feature_normalizer.adapt(single_feature)
Run Code Online (Sandbox Code Playgroud)

我收到的错误是:

ValueError                                Traceback (most recent call last)
<ipython-input-98-22191285d676> in <module>()
      2 single_feature_model = keras.models.Sequential([
      3     single_feature_normalizer,
----> 4     layers.Dense(1) # Linear Model
      5 ])

/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name)
    225       ndim = x.shape.rank
    226       if ndim is not None and ndim < spec.min_ndim:
--> 227         raise ValueError(f'Input {input_index} of layer "{layer_name}" '
    228                          'is incompatible with the layer: '
    229                          f'expected min_ndim={spec.min_ndim}, ' …
Run Code Online (Sandbox Code Playgroud)

python neural-network keras tensorflow

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

keras ×1

neural-network ×1

python ×1

tensorflow ×1