浏览代码

Merge pull request #10 from bzz/fix/swivel-import

labours: update relative Swivel import
Vadim Markovtsev 7 年之前
父节点
当前提交
dd9dd084d5
共有 2 个文件被更改,包括 4 次插入1 次删除
  1. 2 0
      README.md
  2. 2 1
      labours.py

+ 2 - 0
README.md

@@ -127,6 +127,8 @@ hercules -couples [-people-dict=/path/to/identities]
 python3 labours.py -m couples -o <name> [--couples-tmp-dir=/tmp]
 python3 labours.py -m couples -o <name> [--couples-tmp-dir=/tmp]
 ```
 ```
 
 
+**Important**: it requires Tensorflow to be installed, please follow [official instuctions](https://www.tensorflow.org/install/).
+
 The files are coupled if they are changed in the same commit. The developers are coupled if they
 The files are coupled if they are changed in the same commit. The developers are coupled if they
 change the same file. `hercules` records the number of couples throught the whole commti history
 change the same file. `hercules` records the number of couples throught the whole commti history
 and outputs the two corresponding co-occurrence matrices. `labours.py` then trains
 and outputs the two corresponding co-occurrence matrices. `labours.py` then trains

+ 2 - 1
labours.py

@@ -419,8 +419,9 @@ def train_embeddings(coocc_tree, tmpdir, shard_size=4096):
     from scipy.sparse import csr_matrix
     from scipy.sparse import csr_matrix
     try:
     try:
         from . import swivel
         from . import swivel
-    except SystemError:
+    except (SystemError, ImportError):
         import swivel
         import swivel
+    import tensorflow as tf
 
 
     index = coocc_tree["index"]
     index = coocc_tree["index"]
     nshards = len(index) // shard_size
     nshards = len(index) // shard_size