Update a few keras tests that will fail after converting to OSS tests.

PiperOrigin-RevId: 335451981
Change-Id: Iea48875cfa99a0baf2b8d3fcc13f54189b090228
This commit is contained in:
Scott Zhu 2020-10-05 10:51:19 -07:00 committed by TensorFlower Gardener
parent 0e87b6606e
commit 59d93ae10b
2 changed files with 10 additions and 9 deletions
tensorflow/python/keras/layers

View File

@ -29,6 +29,7 @@ from tensorflow.python.keras.engine.base_layer import Layer
from tensorflow.python.keras.engine.input_spec import InputSpec
from tensorflow.python.keras.utils import conv_utils
from tensorflow.python.keras.utils import tf_utils
from tensorflow.python.ops import sparse_ops
from tensorflow.python.util.tf_export import keras_export
@ -807,7 +808,7 @@ def local_conv_sparse_matmul(inputs, kernel, kernel_idxs, kernel_shape,
Output (N+2)-D dense tensor with shape `output_shape`.
"""
inputs_flat = K.reshape(inputs, (K.shape(inputs)[0], -1))
output_flat = K.sparse_ops.sparse_tensor_dense_mat_mul(
output_flat = sparse_ops.sparse_tensor_dense_mat_mul(
kernel_idxs, kernel, kernel_shape, inputs_flat, adjoint_b=True)
output_flat_transpose = K.transpose(output_flat)

View File

@ -21,7 +21,7 @@ from __future__ import print_function
import numpy as np
from tensorflow.python import keras
from tensorflow.python.keras.backend import dtypes_module
from tensorflow.python.framework import dtypes
from tensorflow.python.keras import keras_parameterized
from tensorflow.python.keras import testing_utils
from tensorflow.python.platform import test
@ -48,7 +48,7 @@ class NoiseLayersTest(keras_parameterized.TestCase):
@staticmethod
def _make_model(dtype, class_type):
assert dtype in (dtypes_module.float32, dtypes_module.float64)
assert dtype in (dtypes.float32, dtypes.float64)
assert class_type in ('gaussian_noise', 'gaussian_dropout', 'alpha_noise')
model = keras.Sequential()
model.add(keras.layers.Dense(8, input_shape=(32,), dtype=dtype))
@ -70,22 +70,22 @@ class NoiseLayersTest(keras_parameterized.TestCase):
model.train_on_batch(np.zeros((8, 32)), np.zeros((8, 8)))
def test_noise_float32(self):
self._train_model(dtypes_module.float32, 'gaussian_noise')
self._train_model(dtypes.float32, 'gaussian_noise')
def test_noise_float64(self):
self._train_model(dtypes_module.float64, 'gaussian_noise')
self._train_model(dtypes.float64, 'gaussian_noise')
def test_dropout_float32(self):
self._train_model(dtypes_module.float32, 'gaussian_dropout')
self._train_model(dtypes.float32, 'gaussian_dropout')
def test_dropout_float64(self):
self._train_model(dtypes_module.float64, 'gaussian_dropout')
self._train_model(dtypes.float64, 'gaussian_dropout')
def test_alpha_dropout_float32(self):
self._train_model(dtypes_module.float32, 'alpha_noise')
self._train_model(dtypes.float32, 'alpha_noise')
def test_alpha_dropout_float64(self):
self._train_model(dtypes_module.float64, 'alpha_noise')
self._train_model(dtypes.float64, 'alpha_noise')
if __name__ == '__main__':