2017-01-12 4 views
0

フィーチャリストの値リストはどのように渡されますか?ドキュメントはこれが有効であることを示唆していますが、リストの結果がエラーになった場合、これがどのように達成されるかは不明です。tf.train.SequenceExample各ステップのリスト

>>> tf.train.SequenceExample().feature_lists.feature_list["multiple"].feature.add().int64_list.value.append([1,2,3,4]) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal /containers.py", line 251, in append 
    self._values.append(self._type_checker.CheckValue(value)) 
    File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal /type_checkers.py", line 132, in CheckValue 
raise TypeError(message) 
TypeError: [1, 2, 3, 4] has type <type 'list'>, but expected one of: (<type 'int'>, <type 'long'>) 

これはprotoファイルの例です。 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/example/example.proto

// Conditionally conformant FeatureLists, the parser configuration determines 
// if the feature sizes must match: 
// feature_lists: { feature_list: { 
//  key: "movie_ratings" 
//  value: { feature: { float_list: { value: [ 4.5 ] } } 
//    feature: { float_list: { value: [ 5.0, 6.0 ] } } } 
// } } 

リストを追加する場合は、APPEND以外のものを使用することが必要ですか?

配列の例は、このシーケンス内の4つのステップがあり、各ステップにおける値のセットがある...

[[1,2,3],[4,5],[6,7],[8,9,10]] 

...あろう。希望の結果は、以下の例のようになります。

feature_lists: { feature_list: { 
     key: "movie_ratings" 
     value: { feature: { float_list: { value: [ 1, 2, 3 ] } } 
       feature: { float_list: { value: [ 4, 5 ] } } 
       feature: { float_list: { value: [ 6, 7 ] } } 
       feature: { float_list: { value: [ 8, 9, 10 ] } } } 
    } } 

答えて

0

appendの代わりにextendを使用します。

tf.train.SequenceExample().feature_lists.feature_list["multiple"].feature.add().int64_list.value.extend([1,2,3,4]) 
関連する問題