Uni のプロジェクトでは、TensorFlow のニューラル ネットを使用した質問応答 (現時点では bAbI データセット タスク 5、https: //research.fb.com/downloads/babi/ を参照) システムの実装に取り組んでいます。入力パイプラインに TFRecords を使用したいと考えています。
私の考えでは、TFRecords 用語の 1 つの例は、質問のコンテキスト、質問自体、回答、およびサポート センテンス番号 (int は、質問に回答できるコンテキストで最も重要な文を指します) で構成する必要があります。 . 関数を定義した方法は次のとおりです。
def make_example(context, question, answer, support):
ex = tf.train.SequenceExample()
fl_context = ex.feature_lists.feature_list["context"]
fl_question = ex.feature_lists.feature_list["question"]
fl_answer = ex.feature_lists.feature_list["answer"]
ex.context.feature["support"].int64_list.value.append(support)
for token in context:
fl_context.feature.add().int64_list.value.append(token)
for qWord in question:
fl_question.feature.add().int64_list.value.append(qWord)
for ansWord in answer:
fl_answer.feature.add().int64_list.value.append(ansWord)
fl_support.feature.add().int64_list.value.append(support)
return ex
ただし、コンテキスト、質問、および回答を渡す前に、単語を埋め込み、GloVe ベクトル、つまり (m,d) 行列で表現したいと考えています。ここで、m は文内のトークンの数であり、d は各単語ベクトルの次元数。make_example
私が得るように、これは私の関数によってうまく処理されないようです:
theTypeError: (array([[ -9.58490000e-01, 1.73210000e-01,
2.51650000e-01,
-5.61450000e-01, -1.21440000e-01, 1.54350000e+00,
-1.28930000e+00, -9.77790000e-01, -1.35480000e-01,
-6.06930000e-01, -1.37810000e+00, 6.33470000e-01,
1.33160000e-01, 2.46320000e-01, 6.60260000e-01,
-4.46130000e-02, 4.09510000e-01, -7.61670000e-01,
4.67530000e-01, -6.67810000e-01, 2.99850000e-01,
-2.74810000e-01, -5.47990000e-01, -8.56820000e-01,
5.30880000e-02, -2.01700000e+00, 7.48530000e-01,
-1.27830000e-01, 1.32050000e-01, -2.19450000e-01,
2.29830000e+00, -3.17680000e-01, -8.64940000e-01,
-1.08630000e-01, -8.13770000e-02, -7.03420000e-01,
4.60000000e-01, -3.34730000e-01, 4.37030000e-02,
-7.55080000e-01, -6.89710000e-01, 7.14380000e-01,
-8.35950000e-02, 1.58620000e-02, -5.23850000e-01,
1.72520000e-01, -4.98740000e-01, 2.30810000e-01,
-3.64690000e-01, 1.5 has type <class 'tuple'>, but expected one of:
(<class 'int'>,)
上記を指して fl_context.feature.add().int64_list.value.append(token)
...誰かが私がTFRecordsの概念を誤解した場所を指摘し、問題に取り組む方法をアドバイスしてもらえますか?
学習教材をたくさん検索しましたが、通常、TFRecords の例は画像データを使用しています。これまでのところ、私の参考文献はhttps://medium.com/@TalPerry/getting-text-into-tensorflow-with-the-dataset-api-ffb832c8bec6とhttp://web.stanford.edu/class/cs20si/lectures/です。 notes_09.pdf .
よろしくお願いします!