前几天我读过有关tensorflow的文本分类,我在github上找到了这个代表,并根据示例构建了我自己的模型:https://github.com/dmesquita/understanding_tensorflow_nn
效果很好,但我不明白:
for text in texts:
layer = np.zeros(total_words,dtype=float)
for word in text.split(' '):
layer[word2index[word.lower()]] += 1
当第二次出现相同的单词时,它会增加图层中的值(+ = 1),但是归一化在哪里?我读到神经网络的输入值为0到1之间。我扫描了所有代码,但找不到规范化。任何机构都可以解释,为什么?这是错误的例子吗?
第二个问题,当我们在这个例子中构建词汇时,我们使用Counter():
for text in newsgroups_train.data:
for word in text.split(' '):
vocab[word.lower()]+=1
我们每次抓到一个词时都会增加词汇元素,为什么?我们以后不再使用它。