Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
2dfcc4f1
Commit
2dfcc4f1
authored
Dec 22, 2016
by
Neal Wu
Browse files
Word2vec can now be run if the users compile the ops on their own
parent
a8ab7347
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
15 deletions
+9
-15
tutorials/embedding/README.md
tutorials/embedding/README.md
+7
-11
tutorials/embedding/__init__.py
tutorials/embedding/__init__.py
+0
-2
tutorials/embedding/word2vec.py
tutorials/embedding/word2vec.py
+1
-1
tutorials/embedding/word2vec_optimized.py
tutorials/embedding/word2vec_optimized.py
+1
-1
No files found.
tutorials/embedding/README.md
View file @
2dfcc4f1
...
@@ -9,7 +9,7 @@ tutorials. Brief instructions are below.
...
@@ -9,7 +9,7 @@ tutorials. Brief instructions are below.
*
[
Word2Vec Tutorial
](
http://tensorflow.org/tutorials/word2vec
)
*
[
Word2Vec Tutorial
](
http://tensorflow.org/tutorials/word2vec
)
To download the example text and evaluation data:
Assuming you have cloned the git repository, navigate into this directory.
To download the example text and evaluation data:
```
shell
```
shell
wget http://mattmahoney.net/dc/text8.zip
-O
text8.zip
wget http://mattmahoney.net/dc/text8.zip
-O
text8.zip
...
@@ -19,21 +19,17 @@ unzip -p source-archive.zip word2vec/trunk/questions-words.txt > questions-word
...
@@ -19,21 +19,17 @@ unzip -p source-archive.zip word2vec/trunk/questions-words.txt > questions-word
rm
source-archive.zip
rm
source-archive.zip
```
```
Assuming you have cloned the git repository, navigate into this directory and
You will need to compile the ops as follows:
run using:
```
shell
```
shell
cd
models/tutorials/embedding
TF_INC
=
$(
python
-c
'import tensorflow as tf; print(tf.sysconfig.get_include())'
)
python word2vec_optimized.py
\
g++
-std
=
c++11
-shared
word2vec_ops.cc word2vec_kernels.cc
-o
word2vec_ops.so
-fPIC
-I
$TF_INC
-O2
--train_data
=
text8
\
--eval_data
=
questions-words.txt
\
--save_path
=
/tmp/
```
```
T
o run the code from sources using bazel
:
T
hen run using
:
```
shell
```
shell
bazel run
-c
opt models/tutorials/embedding/
word2vec_optimized
--
\
python
word2vec_optimized
.py
\
--train_data
=
text8
\
--train_data
=
text8
\
--eval_data
=
questions-words.txt
\
--eval_data
=
questions-words.txt
\
--save_path
=
/tmp/
--save_path
=
/tmp/
...
...
tutorials/embedding/__init__.py
View file @
2dfcc4f1
...
@@ -17,5 +17,3 @@
...
@@ -17,5 +17,3 @@
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
print_function
import
gen_word2vec
tutorials/embedding/word2vec.py
View file @
2dfcc4f1
...
@@ -42,7 +42,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin
...
@@ -42,7 +42,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin
import
numpy
as
np
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
import
gen_word2vec
as
word2vec
word2vec
=
tf
.
load_op_library
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'/word2vec_ops.so'
)
flags
=
tf
.
app
.
flags
flags
=
tf
.
app
.
flags
...
...
tutorials/embedding/word2vec_optimized.py
View file @
2dfcc4f1
...
@@ -41,7 +41,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin
...
@@ -41,7 +41,7 @@ from six.moves import xrange # pylint: disable=redefined-builtin
import
numpy
as
np
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
import
gen_word2vec
as
word2vec
word2vec
=
tf
.
load_op_library
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
+
'/word2vec_ops.so'
)
flags
=
tf
.
app
.
flags
flags
=
tf
.
app
.
flags
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment