Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tutorials/embedding/word2vec_kernels.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ class SkipgramWord2vecOp : public OpKernel {
vocab_size_ = static_cast<int32>(1 + ordered.size());
Tensor word(DT_STRING, TensorShape({vocab_size_}));
Tensor freq(DT_INT32, TensorShape({vocab_size_}));
word.flat<string>()(0) = "UNK";
word.flat<tstring>()(0) = "UNK";
static const int32 kUnkId = 0;
std::unordered_map<string, int32> word_id;
int64 total_counted = 0;
for (std::size_t i = 0; i < ordered.size(); ++i) {
const auto& w = ordered[i].first;
auto id = i + 1;
word.flat<string>()(id) = w;
word.flat<tstring>()(id) = w;
auto word_count = ordered[i].second;
freq.flat<int32>()(id) = word_count;
total_counted += word_count;
Expand Down