Skip to content

Commit 4f10e7b

Browse files
maciejkulaTensorFlow Recommenders Team
authored and
TensorFlow Recommenders Team
committed
Do not raise an exception when projection dim in the Cross layer is too large.
Work around pypa/pip#9835. PiperOrigin-RevId: 370560208
1 parent 129ea50 commit 4f10e7b

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

tensorflow_recommenders/layers/feature_interaction/dcn.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ def build(self, input_shape):
122122
use_bias=self._use_bias,
123123
)
124124
else:
125-
if self._projection_dim < 0 or self._projection_dim > last_dim / 2:
126-
raise ValueError(
127-
"`projection_dim` should be smaller than last_dim / 2 to improve "
128-
"the model efficiency, and should be positive. Got "
129-
"`projection_dim` {}, and last dimension of input {}".format(
130-
self._projection_dim, last_dim))
131125
self._dense_u = tf.keras.layers.Dense(
132126
self._projection_dim,
133127
kernel_initializer=self._kernel_initializer,

tensorflow_recommenders/layers/feature_interaction/dcn_test.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ def test_one_input(self):
4949
self.evaluate(tf.compat.v1.global_variables_initializer())
5050
self.assertAllClose(np.asarray([[0.16, 0.32, 0.48]]), output)
5151

52-
def test_invalid_proj_dim(self):
53-
with self.assertRaisesRegexp(ValueError,
54-
r"should be smaller than last_dim / 2"):
55-
x0 = np.random.random((12, 5))
56-
x = np.random.random((12, 5))
57-
layer = Cross(projection_dim=6)
58-
layer(x0, x)
59-
6052
def test_unsupported_input_dim(self):
6153
with self.assertRaisesRegexp(ValueError,
6254
r"dimension mismatch"):

tools/build_scripts/utils.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ function create_virtualenv() {
1010
mkdir -p ~/virtualenv
1111
pushd ~/virtualenv
1212
rm -rf $env_name
13-
virtualenv -p $env_python $env_name
13+
virtualenv --no-pip -p $env_python $env_name
1414
source $env_name/bin/activate
15-
pip install --upgrade pip
15+
# Keep using an old version of pip to work around
16+
# https://github.com/pypa/pip/blob/6d636902d7712f77abdb4428c290ba9bdbe70d9c/news/9831.bugfix.rst
17+
python -m ensurepip
18+
python -m pip install -U pip==21.0.1
19+
pip install "pip==21.0.1"
20+
pip --version
1621
popd
1722
}
1823

0 commit comments

Comments
 (0)