loss变NAN

最近使用tensorflow训练程序,train时loss正常,test时总是NAN,最后发现是test的数据没有办法通过hashtable将字符串映射为正常的int(hashtable中没有test的数据标签,导致总是越界,输出默认值-1)所以变nan。

tf.contrib.lookup.index_table_from_tensor 使用详解

Sample Usages:

mapping_strings = tf.constant(["emerson", "lake", "palmer"])
table = tf.contrib.lookup.index_table_from_tensor(
    mapping=mapping_strings, num_oov_buckets=1, default_value=-1)
features = tf.constant(["emerson", "lake", "and", "palmer"])
ids = table.lookup(features)
...
tf.tables_initializer().run()

ids.eval()  ==> [0, 1, 4, 2]

Args:

    mapping: A 1-D Tensor that specifies the mapping of keys to indices. The type of this object must be castable to dtype.
    num_oov_buckets: The number of out-of-vocabulary buckets.
    default_value: The value to use for out-of-vocabulary feature values. Defaults to -1.
    hasher_spec: A HasherSpec to specify the hash function to use for assignment of out-of-vocabulary buckets.
    dtype: The type of values passed to lookup. Only string and integers are supported.
    name: A name for this op (optional).

Returns:

The lookup table to map an input Tensor to index int64 Tensor.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值