Open vdhanraj opened 9 months ago
kws lib does not use or import LocallyConnected1D explicitly (full log can be helpful to see where the error happened). kws lib is at sync with HEAD of TF, so please try tf_nightly.
Hi @rybakov,
I'm currently using tf-nightly (tf-nightly==2.16.0.dev20231209), is this an acceptable version of tf-nightly?
Here's the full error log: 3 import logging 4 from kws_streaming.models import model_flags ----> 5 from kws_streaming.models import models 6 from kws_streaming.layers.modes import Modes 7 from kws_streaming.train import test
File ~/Desktop/kws_streaming/colab/./google-research/kws_streaming/models/models.py:17 1 # coding=utf-8 2 # Copyright 2023 The Google Research Authors. 3 # (...) 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 16 """Supported models.""" ---> 17 import kws_streaming.models.att_mh_rnn as att_mh_rnn 18 import kws_streaming.models.att_rnn as att_rnn 19 import kws_streaming.models.bc_resnet as bc_resnet
File ~/Desktop/kws_streaming/colab/./google-research/kws_streaming/models/att_mh_rnn.py:18 16 """BiRNN model with multihead attention.""" 17 from kws_streaming.layers import modes ---> 18 from kws_streaming.layers import speech_features 19 from kws_streaming.layers.compat import tf 20 import kws_streaming.models.model_utils as utils
File ~/Desktop/kws_streaming/colab/./google-research/kws_streaming/layers/speech_features.py:26 24 from kws_streaming.layers import random_shift 25 from kws_streaming.layers import random_stretch_squeeze ---> 26 from kws_streaming.layers import spectrogram_augment 27 from kws_streaming.layers import spectrogram_cutout 28 from kws_streaming.layers import windowing
File ~/Desktop/kws_streaming/colab/./google-research/kws_streaming/layers/spectrogram_augment.py:20 17 from typing import Any, Dict 19 import tensorflow as tf ---> 20 import tensorflow_model_optimization as tfmot 22 from kws_streaming.layers.compat import tf 23 from tensorflow.python.ops import array_ops # pylint: disable=g-direct-tensorflow-import
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/init.py:86
82 # To ensure users only access the expected public API, the API structure is
83 # created in the api
directory. Import all api modules.
84 from tensorflow_model_optimization.python.core import version
---> 86 from tensorflow_model_optimization.python.core.api import clustering
87 from tensorflow_model_optimization.python.core.api import experimental
88 from tensorflow_model_optimization.python.core.api import quantization
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/api/init.py:16 1 # Copyright 2021 The TensorFlow Authors. All Rights Reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); (...) 13 # limitations under the License. 14 # ============================================================================== 15 """Import API modules for Tensorflow Model Optimization.""" ---> 16 from tensorflow_model_optimization.python.core.api import clustering 17 from tensorflow_model_optimization.python.core.api import experimental 18 from tensorflow_model_optimization.python.core.api import quantization
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/api/clustering/init.py:16 1 # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); (...) 13 # limitations under the License. 14 # ============================================================================== 15 """Module containing code for clustering.""" ---> 16 from tensorflow_model_optimization.python.core.api.clustering import keras
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/api/clustering/keras/init.py:19 16 # pylint: disable=g-bad-import-order 17 from tensorflow_model_optimization.python.core.clustering.keras import experimental ---> 19 from tensorflow_model_optimization.python.core.clustering.keras.cluster import cluster_scope 20 from tensorflow_model_optimization.python.core.clustering.keras.cluster import cluster_weights 21 from tensorflow_model_optimization.python.core.clustering.keras.cluster import strip_clustering
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/cluster.py:22 19 import tensorflow as tf 21 from tensorflow_model_optimization.python.core.clustering.keras import cluster_config ---> 22 from tensorflow_model_optimization.python.core.clustering.keras import cluster_wrapper 23 from tensorflow_model_optimization.python.core.clustering.keras import clustering_centroids 25 k = tf.keras.backend
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/cluster_wrapper.py:24 22 from tensorflow_model_optimization.python.core.clustering.keras import clusterable_layer 23 from tensorflow_model_optimization.python.core.clustering.keras import clustering_centroids ---> 24 from tensorflow_model_optimization.python.core.clustering.keras import clustering_registry 26 attrgetter = operator.attrgetter # pylint: disable=invalid-name 27 keras = tf.keras
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/clustering_registry.py:57 53 return ans 54 return ClusteringAlgorithm ---> 57 class ClusteringRegistry(object): 58 """Registry responsible for built-in keras layers.""" 60 # The keys represent built-in keras layers and the values represent the 61 # the variables within the layers which hold the kernel weights. This 62 # allows the wrapper to access and modify the weights.
File ~/.local/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/clustering_registry.py:76, in ClusteringRegistry() 58 """Registry responsible for built-in keras layers.""" 60 # The keys represent built-in keras layers and the values represent the 61 # the variables within the layers which hold the kernel weights. This 62 # allows the wrapper to access and modify the weights. 63 _LAYERS_WEIGHTS_MAP = { 64 layers.Conv1D: ['kernel'], 65 layers.Conv1DTranspose: ['kernel'], 66 layers.Conv2D: ['kernel'], 67 layers.Conv2DTranspose: ['kernel'], 68 layers.Conv3D: ['kernel'], 69 layers.Conv3DTranspose: ['kernel'], 70 # non-clusterable due to big unrecoverable accuracy loss 71 layers.DepthwiseConv2D: [], 72 layers.SeparableConv1D: ['pointwise_kernel'], 73 layers.SeparableConv2D: ['pointwise_kernel'], 74 layers.Dense: ['kernel'], 75 layers.Embedding: ['embeddings'], ---> 76 layers.LocallyConnected1D: ['kernel'], 77 layers.LocallyConnected2D: ['kernel'], 78 layers.BatchNormalization: [], 79 layers.LayerNormalization: [], 80 } 82 _SUPPORTED_RNN_CELLS = frozenset({ 83 # Sometimes v2 RNN will wrap some v1 RNN cells and we need 84 # to consider this (...) 92 tf.compat.v2.keras.layers.StackedRNNCells, 93 }) 95 _SUPPORTED_RNN_LAYERS = frozenset([ 96 layers.GRU, 97 layers.LSTM, (...) 100 layers.Bidirectional, 101 ])
AttributeError: module 'keras._tf_keras.keras.layers' has no attribute 'LocallyConnected1D'
My guess is that you are using outdated version of tensorflow_model_optimization which is mismatched with tf. So I would suggest to update tensorflow_model_optimization
Hi @rybakov, thanks for the suggestion. I updated tensorflow_model_optimization, which solved the above issue, but was still running into problems where the code was referencing tf._keras_internal, which doesn't seem to exist. Maybe I'm using a different version of tf_nightly, or something else is out of date, but I've gotten the code to work by either removing or replacing occurrences of tf_keras_internal. Let me know if there is an alternative solution.
@rybakov The code is still not working, removing references to internal variables made the code crash at later points in the pipeline. I don't think the code works properly with the current version of tf-nightly, is it possible to update the code so that it is compatible?
@rybakov The code is still not working, removing references to internal variables made the code crash at later points in the pipeline. I don't think the code works properly with the current version of tf-nightly, is it possible to update the code so that it is compatible?
did the problem solved ? I could able find tf_nightly-2.3.0.dev20200515-cp36-cp36m-manylinux2010_x86_64.whl version
Hi,
I'm running into some import errors when trying to run the 00_check_data notebook in colab. When importing kws_streaming.models import models, I get an error saying module 'keras._tf_keras.keras.layers' has no attribute 'LocallyConnected1D'.
I've followed the instructions on kws_experiments_paper_12_labels.md to install the packages that should be required to run the code, but it still isn't working. The .md file specifies that the code worked on tf_nightly-2.3.0.dev20200515-cp36-cp36m-manylinux2010_x86_64.whl, but tf_nightly doesn't have that version available to download via pip anymore, so I'm not sure how to obtain it. Does anyone know what I need to install to get this code working?