Skip to content

Commit c4abd88

Browse files
committed
Merge remote-tracking branch 'upstream/master' into import-fixes
2 parents 170fb15 + 2b883c7 commit c4abd88

File tree

3 files changed

+26
-55
lines changed

3 files changed

+26
-55
lines changed

g3doc/install.md

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Learning (NSL) in TensorFlow:
1111
`pip` package manager.
1212
* If you have a unique machine configuration,
1313
[build NSL](#build-the-neural-structured-learning-pip-package) from source.
14-
* You can also use [Docker for installing NSL](#using-docker).
1514

1615
## Install Neural Structured Learning using pip
1716

@@ -54,7 +53,7 @@ Note: To exit the virtual environment, run `deactivate`.
5453
#### 4. (Optional) Test Neural Structured Learning.
5554

5655
<pre class="prettyprint lang-bsh">
57-
<code class="devsite-terminal tfo-terminal-venv">python -c "import neural_structured_learning as nsl</code>
56+
<code class="devsite-terminal tfo-terminal-venv">python -c "import neural_structured_learning as nsl"</code>
5857
</pre>
5958

6059
Success: Neural Structured Learning is now installed.
@@ -105,8 +104,8 @@ Note: To exit the virtual environment, run `deactivate`.
105104
### 5. Install Neural Structured Learning dependencies.
106105

107106
<pre class="prettyprint lang-bsh">
108-
<code class="devsite-terminal">cd neural_structured_learning</code>
109-
<code class="devsite-terminal tfo-terminal-venv">pip install --requirement "requirements.txt"</code>
107+
<code class="devsite-terminal">cd neural-structured-learning</code>
108+
<code class="devsite-terminal tfo-terminal-venv">pip install --requirement neural_structured_learning/requirements.txt</code>
110109
</pre>
111110

112111
### 6. (Optional) Unit Test Neural Structured Learning.
@@ -115,51 +114,22 @@ Note: To exit the virtual environment, run `deactivate`.
115114
<code class="devsite-terminal tfo-terminal-venv">bazel test //neural_structured_learning/...</code>
116115
</pre>
117116

118-
#### 7. Test Neural Structured Learning.
117+
### 7. Build the pip package.
119118

120119
<pre class="prettyprint lang-bsh">
121-
<code class="devsite-terminal tfo-terminal-venv">python -c "import neural_structured_learning as nsl</code>
120+
<code class="devsite-terminal tfo-terminal-venv">python setup.py bdist_wheel --universal --dist-dir="./wheel"</code>
122121
</pre>
123122

124-
Success: The Neural Structured Learning package is built.
125-
126-
## Using Docker
127-
128-
Create a Neural Structured Learning development environment using Docker on
129-
Ubuntu or macOS.
130-
131-
### 1. Install Docker.
132-
133-
[Install Docker](https://docs.docker.com/install/) on your local machine.
134-
135-
### 2. Clone the latest Neural Structured Learning source.
136-
137-
<pre class="prettyprint lang-bsh">
138-
<code class="devsite-terminal">git clone https://github.com/tensorflow/neural-structured-learning.git</code>
139-
<code class="devsite-terminal">cd neural_structured_learning</code>
140-
</pre>
141-
142-
### 3. Build a Docker image.
143-
144-
<pre class="prettyprint lang-bsh">
145-
<code class="devsite-terminal">docker build . \
146-
--tag neural-structured-learning:latest</code>
147-
</pre>
148-
149-
### 4. Start a Docker container.
123+
### 8. Install the pip package.
150124

151125
<pre class="prettyprint lang-bsh">
152-
<code class="devsite-terminal">docker run -it \
153-
--workdir /neural_structured_learning \
154-
--volume $(pwd):/neural_structured_learning \
155-
neural-structured-learning:latest \
156-
bash</code>
126+
<code class="devsite-terminal tfo-terminal-venv">pip install --upgrade ./wheel/neural_structured_learning*.whl</code>
157127
</pre>
158128

159-
### 5. (Optional) Test Neural Structured Learning.
129+
### 9. Test Neural Structured Learning.
160130

161131
<pre class="prettyprint lang-bsh">
162-
<code class="devsite-terminal">bazel test //neural_structured_learning/...</code>
132+
<code class="devsite-terminal tfo-terminal-venv">python -c "import neural_structured_learning as nsl"</code>
163133
</pre>
164134

165-
Success: The Neural Structured Learning development environment is ready.
135+
Success: The Neural Structured Learning package is built.

g3doc/tutorials/graph_keras_lstm_imdb.ipynb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@
645645
"outputs": [],
646646
"source": [
647647
"!python -m neural_structured_learning.tools.pack_nbrs \\\n",
648-
"--max_nbrs=1 --add_undirected_edges=True \\\n",
648+
"--max_nbrs=3 --add_undirected_edges=True \\\n",
649649
"/tmp/imdb/train_data.tfr '' /tmp/imdb/graph_99.tsv \\\n",
650650
"/tmp/imdb/nsl_train_data.tfr"
651651
]
@@ -743,13 +743,13 @@
743743
" ### neural graph learning parameters\n",
744744
" self.distance_type = nsl.configs.DistanceType.L2\n",
745745
" self.graph_regularization_multiplier = 0.1\n",
746-
" self.num_neighbors = 1\n",
746+
" self.num_neighbors = 2\n",
747747
" ### model architecture\n",
748748
" self.num_embedding_dims = 16\n",
749749
" self.num_lstm_dims = 64\n",
750750
" self.num_fc_units = 64\n",
751751
" ### training parameters\n",
752-
" self.train_epochs = 4\n",
752+
" self.train_epochs = 10\n",
753753
" self.batch_size = 128\n",
754754
" ### eval parameters\n",
755755
" self.eval_steps = None # All instances in the test set are evaluated.\n",
@@ -1459,11 +1459,12 @@
14591459
"# Accuracy values for both the Bi-LSTM model and the feed forward NN model have\n",
14601460
"# been precomputed for the following supervision ratios.\n",
14611461
"\n",
1462-
"supervision_ratios = [0.3, 0.15, 0.05, 0.03, 0.01]\n",
1462+
"supervision_ratios = [0.3, 0.15, 0.05, 0.03, 0.02, 0.01, 0.005]\n",
14631463
"\n",
14641464
"model_tags = ['Bi-LSTM model', 'Feed Forward NN model']\n",
1465-
"base_model_accs = [[85, 85, 62, 58, 50], [85, 79, 61, 53, 50]]\n",
1466-
"graph_reg_model_accs = [[85, 84, 76, 63, 51], [85, 79, 73, 62, 50]]\n",
1465+
"base_model_accs = [[84, 84, 83, 80, 65, 52, 50], [87, 86, 76, 74, 67, 52, 51]]\n",
1466+
"graph_reg_model_accs = [[84, 84, 83, 83, 65, 63, 50],\n",
1467+
" [87, 86, 80, 75, 67, 52, 50]]\n",
14671468
"\n",
14681469
"plt.clf() # clear figure\n",
14691470
"\n",
@@ -1498,12 +1499,12 @@
14981499
"It can be observed that as the superivision ratio decreases, model accuracy also\n",
14991500
"decreases. This is true for both the base model and for the graph-regularized\n",
15001501
"model, regardless of the model architecture used. However, notice that the\n",
1501-
"graph-regularized model is consistenly better than the base model -- sometimes\n",
1502-
"by as much as 15% -- and further, as the supervision ratio decreases, the\n",
1503-
"decrease in accuracy is much less for the graph-regularized model than the base\n",
1504-
"model. This is primarily because of semi-supervised learning for the\n",
1505-
"graph-regularized model, where structural similarity among training samples is\n",
1506-
"used in addition to the training samples themselves."
1502+
"graph-regularized model performs better than the base model for both the\n",
1503+
"architectures. In particular, for the Bi-LSTM model, when the supervision ratio\n",
1504+
"is 0.01, the accuracy of the graph-regularized model is **~20%** higher than\n",
1505+
"that of the base model. This is primarily because of semi-supervised learning\n",
1506+
"for the graph-regularized model, where structural similarity among training\n",
1507+
"samples is used in addition to the training samples themselves."
15071508
]
15081509
},
15091510
{

neural_structured_learning/tools/build_docs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
2626
```shell
2727
python build_docs.py \
28-
--out_dir=/tmp/neural_structured_learning_api
28+
--output_dir=/tmp/neural_structured_learning_api
2929
```
3030
3131
Note:
@@ -47,7 +47,7 @@
4747
from tensorflow_docs.api_generator import generate_lib
4848
from tensorflow_docs.api_generator import public_api
4949

50-
flags.DEFINE_string("out_dir", "/tmp/neural_structured_learning_api",
50+
flags.DEFINE_string("output_dir", "/tmp/neural_structured_learning_api",
5151
"Where to output the docs")
5252
flags.DEFINE_string(
5353
"code_url_prefix",
@@ -79,7 +79,7 @@ def main(_):
7979
# documented in the location that defines them, instead of every location
8080
# that imports them.
8181
callbacks=[public_api.local_definitions_filter])
82-
doc_generator.build(output_dir=FLAGS.out_dir)
82+
doc_generator.build(output_dir=FLAGS.output_dir)
8383

8484

8585
if __name__ == "__main__":

0 commit comments

Comments
 (0)