Skip to content

Commit 1798069

Browse files
committed
Merge remote-tracking branch 'upstream/master' into vat
# Conflicts: # neural_structured_learning/research/gam/data/dataset.py # neural_structured_learning/research/gam/data/loaders.py # neural_structured_learning/research/gam/experiments/helper.py # neural_structured_learning/research/gam/experiments/run_train_gam.py # neural_structured_learning/research/gam/experiments/run_train_gam_graph.py # neural_structured_learning/research/gam/trainer/trainer_agreement.py # neural_structured_learning/research/gam/trainer/trainer_classification.py # neural_structured_learning/research/gam/trainer/trainer_cotrain.py
2 parents 23c7d17 + e63a9e7 commit 1798069

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2563
-1127
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Please see the [release notes](RELEASE.md) for detailed version updates.
9898

9999
[[4] T. Miyato, S. Maeda, M. Koyama and S. Ishii. "Virtual Adversarial Training: a Regularization Method for Supervised and Semi-supervised Learning." ICLR 2016](https://arxiv.org/pdf/1704.03976.pdf)
100100

101-
[[5] D. Juan, C. Lu, Z. Li, F. Peng, A. Timofeev, Y. Chen, Y. Gao, T. Duerig, A. Tomkins and S. Ravi "Graph-RISE: Graph-Regularized Image Semantic Embedding." arXiv 2019](https://arxiv.org/abs/1902.10814)
101+
[[5] D. Juan, C. Lu, Z. Li, F. Peng, A. Timofeev, Y. Chen, Y. Gao, T. Duerig, A. Tomkins and S. Ravi "Graph-RISE: Graph-Regularized Image Semantic Embedding." WSDM 2020](https://arxiv.org/abs/1902.10814)
102102

103103

104104

g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@
5151
"id": "wfqlePz0g6o5"
5252
},
5353
"source": [
54-
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
55-
" <td>\n",
56-
" <a target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/adversarial_keras_cnn_mnist\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n",
57-
" </td>\n",
58-
" <td>\n",
59-
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
60-
" </td>\n",
61-
" <td>\n",
62-
" <a target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
63-
" </td>\n",
64-
"</table>"
54+
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
55+
" \u003ctd\u003e\n",
56+
" \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/adversarial_keras_cnn_mnist\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
57+
" \u003c/td\u003e\n",
58+
" \u003ctd\u003e\n",
59+
" \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
60+
" \u003c/td\u003e\n",
61+
" \u003ctd\u003e\n",
62+
" \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/adversarial_keras_cnn_mnist.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\n",
63+
" \u003c/td\u003e\n",
64+
"\u003c/table\u003e"
6565
]
6666
},
6767
{
@@ -115,7 +115,7 @@
115115
"id": "m58k8nv3YVdf"
116116
},
117117
"source": [
118-
"Install Tensorflow 2.0 to create an interactive developing environment with\n",
118+
"Select TensorFlow 2.x to create an interactive development environment with\n",
119119
"eager execution."
120120
]
121121
},
@@ -129,7 +129,11 @@
129129
},
130130
"outputs": [],
131131
"source": [
132-
"!pip install tensorflow-gpu==2.0.0-rc0"
132+
"try:\n",
133+
" # %tensorflow_version only exists in Colab.\n",
134+
" %tensorflow_version 2.x\n",
135+
"except Exception:\n",
136+
" !pip install --quiet tensorflow-gpu>=2.0.0"
133137
]
134138
},
135139
{
@@ -376,7 +380,7 @@
376380
" x = tf.keras.layers.Conv2D(\n",
377381
" num_filters, hparams.kernel_size, activation='relu')(\n",
378382
" x)\n",
379-
" if i < len(hparams.conv_filters) - 1:\n",
383+
" if i \u003c len(hparams.conv_filters) - 1:\n",
380384
" # max pooling between convolutional layers\n",
381385
" x = tf.keras.layers.MaxPooling2D(hparams.pool_size)(x)\n",
382386
" x = tf.keras.layers.Flatten()(x)\n",
@@ -800,25 +804,12 @@
800804
"timestamp": 1566174674305
801805
}
802806
],
803-
"toc_visible": true,
804-
"version": "0.3.2"
807+
"toc_visible": true
805808
},
806809
"kernelspec": {
807810
"display_name": "Python 3",
808811
"language": "python",
809812
"name": "python3"
810-
},
811-
"language_info": {
812-
"codemirror_mode": {
813-
"name": "ipython",
814-
"version": 3
815-
},
816-
"file_extension": ".py",
817-
"mimetype": "text/x-python",
818-
"name": "python",
819-
"nbconvert_exporter": "python",
820-
"pygments_lexer": "ipython3",
821-
"version": "3.7.3"
822813
}
823814
},
824815
"nbformat": 4,

g3doc/tutorials/graph_keras_lstm_imdb.ipynb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,26 @@
114114
"source": [
115115
"## Requirements\n",
116116
"\n",
117-
"1. Install TensorFlow 2.x to create an interactive developing environment with eager execution.\n",
118-
"2. Install the Neural Structured Learning package.\n",
119-
"3. Install tensorflow-hub."
117+
"1. Select TensorFlow 2.x to create an interactive development environment with eager execution.\n",
118+
"2. Install the Neural Structured Learning package.\n",
119+
"3. Install tensorflow-hub."
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": 0,
125+
"metadata": {
126+
"colab": {},
127+
"colab_type": "code",
128+
"id": "yDUe7gk_ztZ-"
129+
},
130+
"outputs": [],
131+
"source": [
132+
"try:\n",
133+
" # %tensorflow_version only exists in Colab.\n",
134+
" %tensorflow_version 2.x\n",
135+
"except Exception:\n",
136+
" !pip install tensorflow-gpu>=2.0.0"
120137
]
121138
},
122139
{
@@ -129,7 +146,6 @@
129146
},
130147
"outputs": [],
131148
"source": [
132-
"!pip install --quiet tensorflow-gpu==2.0.0-rc0\n",
133149
"!pip install --quiet neural-structured-learning\n",
134150
"!pip install --quiet tensorflow-hub"
135151
]
@@ -1550,8 +1566,7 @@
15501566
"timestamp": 1566436775546
15511567
}
15521568
],
1553-
"toc_visible": true,
1554-
"version": "0.3.2"
1569+
"toc_visible": true
15551570
},
15561571
"kernelspec": {
15571572
"display_name": "Python 3",

g3doc/tutorials/graph_keras_mlp_cora.ipynb

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@
5151
"id": "pL9fF9FWI-Q1"
5252
},
5353
"source": [
54-
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
55-
" <td>\n",
56-
" <a target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/graph_keras_mlp_cora\"><img src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" />View on TensorFlow.org</a>\n",
57-
" </td>\n",
58-
" <td>\n",
59-
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"><img src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" />Run in Google Colab</a>\n",
60-
" </td>\n",
61-
" <td>\n",
62-
" <a target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"><img src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" />View source on GitHub</a>\n",
63-
" </td>\n",
64-
"</table>"
54+
"\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
55+
" \u003ctd\u003e\n",
56+
" \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/neural_structured_learning/tutorials/graph_keras_mlp_cora\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
57+
" \u003c/td\u003e\n",
58+
" \u003ctd\u003e\n",
59+
" \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
60+
" \u003c/td\u003e\n",
61+
" \u003ctd\u003e\n",
62+
" \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/neural-structured-learning/blob/master/g3doc/tutorials/graph_keras_mlp_cora.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\n",
63+
" \u003c/td\u003e\n",
64+
"\u003c/table\u003e"
6565
]
6666
},
6767
{
@@ -116,10 +116,27 @@
116116
"id": "hgSLDi0SyBuO"
117117
},
118118
"source": [
119-
"1. Install TensorFlow 2.x to create an interactive developing environment with eager execution.\n",
119+
"1. Select TensorFlow 2.x to create an interactive development environment with eager execution.\n",
120120
"2. Install the Neural Structured Learning package."
121121
]
122122
},
123+
{
124+
"cell_type": "code",
125+
"execution_count": 0,
126+
"metadata": {
127+
"colab": {},
128+
"colab_type": "code",
129+
"id": "gh6K6Onyy5bd"
130+
},
131+
"outputs": [],
132+
"source": [
133+
"try:\n",
134+
" # %tensorflow_version only exists in Colab.\n",
135+
" %tensorflow_version 2.x\n",
136+
"except Exception:\n",
137+
" !pip install tensorflow-gpu>=2.0.0"
138+
]
139+
},
123140
{
124141
"cell_type": "code",
125142
"execution_count": 0,
@@ -130,7 +147,6 @@
130147
},
131148
"outputs": [],
132149
"source": [
133-
"!pip install --quiet tensorflow-gpu==2.0.0-rc0\n",
134150
"!pip install --quiet neural-structured-learning"
135151
]
136152
},
@@ -956,8 +972,7 @@
956972
"timestamp": 1560299386497
957973
}
958974
],
959-
"toc_visible": true,
960-
"version": "0.3.2"
975+
"toc_visible": true
961976
},
962977
"kernelspec": {
963978
"display_name": "Python 3",

neural_structured_learning/BUILD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Description:
1616
# Build rules for TensorFlow Neural Structured Learning.
1717

18+
# Placeholder for internal Python strict compatibility macro.
1819
# Internal annotation for sync
1920

2021
package(default_visibility = ["//visibility:public"])
@@ -27,8 +28,17 @@ py_library(
2728
name = "neural_structured_learning",
2829
srcs = ["__init__.py"],
2930
deps = [
31+
":version",
32+
"//neural_structured_learning/configs",
33+
"//neural_structured_learning/estimator",
3034
"//neural_structured_learning/keras",
3135
"//neural_structured_learning/lib",
3236
"//neural_structured_learning/tools",
3337
],
3438
)
39+
40+
py_library(
41+
name = "version",
42+
srcs = ["version.py"],
43+
srcs_version = "PY2AND3",
44+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Subpackages of Neural Structured Learning."""
22

33
from neural_structured_learning import configs
4+
from neural_structured_learning import estimator
45
from neural_structured_learning import keras
56
from neural_structured_learning import lib
67
from neural_structured_learning import tools
8+
from neural_structured_learning.version import __version__

neural_structured_learning/configs/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# Description:
1616
# Build rules for config libraries in Neural Structured Learning.
1717

18+
# Placeholder for internal Python strict compatibility macro.
19+
1820
package(
1921
default_visibility = ["//visibility:public"],
2022
licenses = ["notice"], # Apache 2.0
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Description:
16+
# Build rules for Estimator APIs in Neural Structured Learning.
17+
18+
# Placeholder for internal Python strict compatibility macro.
19+
# Placeholder for internal Python version compatibility macro.
20+
21+
package(
22+
default_visibility = ["//visibility:public"],
23+
licenses = ["notice"], # Apache 2.0
24+
)
25+
26+
exports_files(["LICENSE"])
27+
28+
py_library(
29+
name = "estimator",
30+
srcs = ["__init__.py"],
31+
srcs_version = "PY2AND3",
32+
deps = [
33+
":adversarial_regularization",
34+
":graph_regularization",
35+
],
36+
)
37+
38+
py_library(
39+
name = "adversarial_regularization",
40+
srcs = ["adversarial_regularization.py"],
41+
srcs_version = "PY2AND3",
42+
deps = [
43+
"//neural_structured_learning/configs",
44+
"//neural_structured_learning/lib",
45+
# package tensorflow
46+
],
47+
)
48+
49+
py_test(
50+
name = "adversarial_regularization_test",
51+
srcs = ["adversarial_regularization_test.py"],
52+
srcs_version = "PY2AND3",
53+
deps = [
54+
":estimator",
55+
"//neural_structured_learning/configs",
56+
# package numpy
57+
# package tensorflow
58+
# package tensorflow framework_test_lib,
59+
],
60+
)
61+
62+
py_library(
63+
name = "graph_regularization",
64+
srcs = ["graph_regularization.py"],
65+
srcs_version = "PY2AND3",
66+
deps = [
67+
"//neural_structured_learning/configs",
68+
"//neural_structured_learning/lib:distances",
69+
"//neural_structured_learning/lib:utils",
70+
# package tensorflow
71+
],
72+
)
73+
74+
py_test(
75+
name = "graph_regularization_test",
76+
srcs = ["graph_regularization_test.py"],
77+
srcs_version = "PY2AND3",
78+
deps = [
79+
":estimator",
80+
# package protobuf,
81+
"//neural_structured_learning/configs",
82+
# package numpy
83+
# package tensorflow
84+
# package tensorflow framework_test_lib,
85+
],
86+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Estimator APIs for Neural Structured Learning.
2+
3+
The implementations here are provided on a strict "as is" basis, without
4+
warranties or conditions of any kind. Also, these implementations may not be
5+
compatible with certain TensorFlow versions (such as 2.0 or above).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
r"""Estimator APIs for Neural Structured Learning.
2+
3+
The current NSL Estimator APIs may not be compatible with certain TensorFlow
4+
versions (such as 2.0 or above).
5+
"""
6+
7+
from neural_structured_learning.estimator.adversarial_regularization import add_adversarial_regularization
8+
from neural_structured_learning.estimator.graph_regularization import add_graph_regularization
9+
10+
__all__ = ['add_adversarial_regularization', 'add_graph_regularization']

0 commit comments

Comments
 (0)