I am using tensorflow's object detection API. I successfully trained with 'ssd_mobilenet_v1_coco_2017_11_17' model, later I moved to another model from the given models but while training process starts it showing the error:
"TypeError: Expected int32, got range <0,3> of type 'range' instead".
This error was thrown for all other models other than the ssd_mobilenet_v1_coco_2017_11_17.
I used 300*300 size images for training for all the models.
Here I attached images of the command prompt window showing the error message.I use tensorflow version is 1.5 and python 3.6.
Please modify
line 154 : tf.constant(range(num_boundaries), dtype=tf.int32),
to tf.constant(list(range(num_boundaries)), dtype=tf.int32)
For further reference :
https://github.com/tensorflow/models/issues/3443
Related
I'm trying to convert PyTorch ml model into Core ML. As shown in this WWDC video, I first converted it to TorchScript Version.
But the problem happens when converting TorchScript Version to Core ML.
As first, I did as follow:
import coremltools as ct
model = ct.convert(
traced_model,
inputs=[ct.TensorType(shape=input_ids.shape), ct.TensorType(shape=attention_mask.shape)],
outputs=[ct.TensorType(shape=decoder_input_ids.shape)]
)
But it was giving me an error saying:
ValueError: The 'shape' argument must not be specified for the outputs, since it is automatically inferred from the input shapes and the ops in the model
So I used following code for converting it to Core ml:
import coremltools as ct
model = ct.convert(
traced_model,
inputs=[ct.TensorType(shape=input_ids.shape), ct.TensorType(shape=attention_mask.shape), ct.TensorType(shape=decoder_input_ids.shape)]
)
This time code block ran successfully, but when I actually downloaded the converted coreml, it was not detecting decoder_input_ids as one of inputs like following:
How can I fix this problem, and what am I doing wrong? Btw the model is Seq2Seq model
I am training a YOLO model and it is working fine during training, but when I try to test it, I get the following error: AttributeError: 'GELU' object has no attribute 'approximate'. The model is using the GELU activation function and I am not sure why this error is occurring. Can anyone help me troubleshoot this issue and fix the model?
The error is associated with this line: self.act = nn.GELU().
OS: Ubuntu 22
ENV: pytorch 1.12
Python: 3.10
in google colaboratory using python, I am trying to load model to classify
I am trying to load keras model using python to classify image, I am getting above error
predict_classes is only available for the Sequential class.
With the Model class, you can use the predict method which will give you a vector of probabilities and then get the argmax of this vector (with np.argmax(y_pred1,axis=1)).
I am a beginner in Machine Learning, and I've got a small doubt!
I have been working on a machine learning code, where I am using tensorflow for predictions of future values. Now, the code uses a dataset which implements One Hot Encoding initially, then the OHE columns are combined and the estimator function is created. For the estimator model, I have used DNN Regressor. There is no Keras used anywhere in the code.
model=tf.estimator.DNNRegressor(hidden_units=[100,100,100],feature_columns=feature_columns,
optimizer=tf.optimizers.Adam(learning_rate=0.01),
activation_fn=tf.nn.relu )
Now, I tried using Pickle for saving. However, I get this error:
AttributeError: Can't pickle local object 'DNNRegressorV2.__init__.<locals>._model_fn'
I tried the same using joblib, but I got the following issue:
PicklingError: Can't pickle <function DNNRegressorV2.__init__.<locals>._model_fn at 0x00000175F1A0E948>: it's not found as tensorflow_estimator.python.estimator.canned.dnn.DNNRegressorV2.__init__.<locals>._model_fn
Following this, I tried this code
tf.keras.models.save_model( model, filepath, overwrite=True,
include_optimizer=True, save_format=None, signatures=None, options=None )
But I got the error:
AttributeError: 'DNNRegressorV2' object has no attribute 'built'
I have also tried other methods such as model.save(), model.to_json(), and also tried saving using API - none of them worked out.
Can someone help me out with the same?
Problem
I have a trained model (that is not mine) on which I can make inferences with Theano backend. I need to run it on Android, so I try to convert this model to Tensorflow lite (.tflite).
Before converting it to .tflite, I try to make the model work with tensorflow backend but I can't do it properly. (python with keras)
What works
This is what I do with the theano model, theano backend, channels-last ordering, it works fine :
with open('Model/definition.json', 'r') as f:
model = model_from_json(f.read())
model.load_weights('Model/weights.h5')
p = model.predict_proba(preprocessed_data)
print_results(p)
the model has only two outputs (detected or not detected) and it works fine.
What does not work
When I just switch backend to tensorflow and run the same code, the model does not detect anything anymore.
What I have tried already
I first thought it was a dim ordering problem as I saw on this pages for example : Converting Theano-based Keras model definition to TensorFlow.
A theano model should use channels-first dimensions.
A tensorflow
model should use channels-last dimensions.
There is also the script from this thread that I tried : https://github.com/keras-team/keras/issues/5374
It does not work for me because I think that my weights are already channels-last ordering ! (This is what I supposed from netron, see picture on Imgur
Last thing I tried was convert_all_kernels_in_model(), but I got this error :
tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value conv2d_1/kernel
[[{{node _retval_conv2d_1/kernel_0_0}}]]
Question
What do you think guy I need to do on my model to make it run with tensorflow backend (in order to convert it to tflite...) ???