我仍然試圖用自己的圖像數據運行Tensorflow。 我能夠從這個例子link在Tensorflow中使用字符串標籤
創建具有conevert_to()函數.tfrecords文件現在我,我想用代碼的網絡免受例如link訓練。
但它在read_and_decode()函數中失敗。我在功能的變化是:
label = tf.decode_raw(features['label'], tf.string)
的錯誤是:
TypeError: DataType string for attr 'out_type' not in list of allowed values: float32, float64, int32, uint8, int16, int8, int64
那麼如何1)閱讀和2)使用字符串標籤中tensorflow培訓。
是'string_to_number'只是爲了將_numeric_字符串轉換爲數字,但?我得到一個任意字符串值的異常(即「test」),而'tf.string_to_number(「20」)'可以正常工作,併產生一個'20.0'tf.float32'張量。 –
是的。如果您有文本字符串標籤並需要將其轉換爲數字,則可以使用['tf.feature_column.categorical_column _ *()'] (https://www.tensorflow.org/api_docs/python/tf/feature_column)API,例如['tf.feature_column.categorical_column_with_vocabulary_list()'](https://www.tensorflow.org/api_docs/python/tf/feature_column/categorical_column_with_vocabulary_list)或['tf.feature_column.categorical_column_with_hash_bucket()' ](https://www.tensorflow.org/api_docs/python/tf/feature_column/categorical_column_with_hash_bucket)。 – mrry