(Python 3.8) TypeError: 'module' object is not callable - typeerror

i tried to use this code here:
Python Scipy FFT wav files
and got the following error:
TypeError: 'module' object is not callable
Any solution for that?

Related

AttributeError: module 'tensorflow.keras.layers' has no attribute 'Rescaling'

When I try:
normalization_layer = layers.Rescaling(1./255)
error message:
AttributeError: module 'tensorflow.keras.layers' has no attribute 'Rescaling'
How to fix it?
I had the same error in v2.5.0
tf.keras.layers.experimental.preprocessing.Rescaling()
I guess this is the "old" way to use this layer
Yes, I used a wrong version of tf. Rescaling in tf v2.70, i used v2.60.
A preprocessing layer which rescales input values to a new range.
Inherits From: Layer, Module
tf.keras.layers.Rescaling(
scale, offset=0.0, **kwargs
)

TypeError: 'AutoTrackable' object is not callable

I am trying to run inference on my trained model following this tutorial. I am using TF 2.1.0 and I have tried with tf-nightly 2.5.0.dev20201202.
But I get TypeError: 'AutoTrackable' object is not callable when I hit the following line detections = detect_fn(input_tensor)
I am aware that
'AutoTrackable' object is not callable in Python
exists but I am not using tensorflow hub and I don't understand how the answer could help me.
Thanks
Try using detect_fn.signatures\['default'](input_tensor)
Changing detections = detect_fn(input_tensor) to
detections = detect_fn.signatures['serving_default'](input_tensor)
fixed the issue for me.

AttributeError: module 'keras.layers' has no attribute 'Wrapper'

This error happens cause I used from astroNN.models import Galaxy10CNN and do downgrade Tensorflow to 1.15.2 to prevent the ImportError: cannot import name 'get_default_session' but see new error related to attribute 'Wrapper' AttributeError: module 'keras.layers' has no attribute 'Wrapper'
Please advise. Thanks!
Use the keras.layers.wrapper in Tensorflow 1.15 as
import tensorflow as tf
tf.keras.layers.Wrapper(layer, **kwargs)
for more details on the library please find here.
With tensorflow version 1.15.2 and astroNN version 1.0.1 a hacky way is to replace line 15 of the file /usr/local/lib/python3.7/dist-packages/astroNN/nn/layers.py (e.g., in linux, with colab)
Layer, Wrapper, InputSpec = tf.keras.layers.Layer, tf.keras.layers.Wrapper, tf.keras.layers.InputSpec

Problem in Keras with 'merge' - TypeError: 'module' object is not callable

I tried to merge layer3, layer4 and layer5 with following line of code:
layer = merge([layer3,layer4,layer5],mode='sum')
But it throws this error:
show the TypeError: 'module' object is not callable
Why is my code not working?
I assume you're trying to run source code written for an older Keras version. 'sum' just adds your layers element wise. You could also use TensorFlow to do the same:
layer = tf.add(layer3, layer4)
layer = tf.add(layer, layer5)

AttributeError: module 'tensorflow.contrib.lite.python.convert_saved_model' has no attribute 'convert'

I am trying to convert my premade DNN Model to tflite file, using the function:
from tensorflow.contrib.lite.python import convert_saved_model
convert_saved_model.convert(saved_model_dir=saved_model, output_tflite="/TF_Lite_Model")
I have the last verison of tensorflow installed 1.10
I am using UBUNTU 16.04
the error is the following:
AttributeError: module 'tensorflow.contrib.lite.python.convert_saved_model' has no attribute 'convert'
The API for converting SavedModels to TensorFlow Lite FlatBuffers is TocoConverter.from_saved_model as documented here. The documentation has been copied below.
To provide a general explanation. from_saved_model is a classmethod that returns a TocoConverter object. TocoConverter has a function convert. convert_saved_model is a function and therefore does not have its own convert function.
Copied from documentation:
The following example shows how to convert a SavedModel into a TensorFlow Lite FlatBuffer.
import tensorflow as tf
converter = tf.contrib.lite.TocoConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
For more complex SavedModels, the optional parameters that can be passed into TocoConverter.from_saved_model() are input_arrays, input_shapes, output_arrays, tag_set and signature_key. Details of each parameter are available by running help(tf.contrib.lite.TocoConverter).
I had to compile the tflite contrib module as it was missing on my repo.