我尝试从官方github仓库开始以下tensorflow模型word2vec示例:
https://github.com/tensorflow/models/tree/master/tutorials/embedding
数据准备工作:
curl http://mattmahoney.net/dc/text8.zip > text8.zip
unzip text8.zip
curl https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/word2vec/source-archive.zip > source-archive.zip
unzip -p source-archive.zip word2vec/trunk/questions-words.txt > questions-words.txt
rm text8.zip source-archive.zip
但是尝试添加自定义tensorflow操作失败,如下所述:
TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') )
结果:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'get_compile_flags'
最新的tensorflow版本(v1.12.0)通过pip安装:
pip install --upgrade tensorflow
python版本是v2.7.15。