【问题标题】:Prefetch Dataset dtype format预取数据集 dtype 格式
【发布时间】:2022-09-05 19:05:49
【问题描述】:

收到此错误。看起来这是由于 train_step_signature 和数据集上的 dtype 不一样?有没有办法将 Prefetch 数据集的格式从 int32 更改为 tf.int64?谢谢


ValueError: Python inputs incompatible with input_signature:
  inputs: (
    tf.Tensor(
[[ 77 111 110 ...   0   0   0]
 [ 83 105 110 ...   0   0   0]
 [ 71  97 115 ...   0   0   0]
 ...
 [ 80 114 111 ...   0   0   0]
 [ 70 114  97 ...   0   0   0]
 [ 65 110 233 ...   0   0   0]], shape=(64, 605), dtype=int32),
    tf.Tensor(
[[ 68 101 115 ...   0   0   0]
 [ 76 101  32 ...   0   0   0]
 [ 76 101  32 ...   0   0   0]
 ...
 [ 68  97 110 ...   0   0   0]
 [ 85 110 101 ...   0   0   0]
 [ 68  97 110 ...   0   0   0]], shape=(64, 936), dtype=int32))
  input_signature: (
    TensorSpec(shape=(None, None), dtype=tf.int64, name=None),
    TensorSpec(shape=(None, None), dtype=tf.int64, name=None)).


【问题讨论】:

    标签: python tensorflow tensorflow-datasets


    【解决方案1】:

    也许试试casting

    dataset = dataset.map(lambda x,y (tf.cast(x, dtype=tf.int64), tf.cast(y, dtype=tf.int64)))
    

    【讨论】:

      猜你喜欢
      • 2016-05-20
      • 2019-08-04
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 2019-09-07
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      相关资源
      最近更新 更多