Comments (12)
Hi,
I encountered a similar issue using TensorFlow 2.4.1.
Here is a minimal snippet to replicate it:
from tensorflow.keras.layers import Input
from tensorflow.keras.models import Model
from tf2cv.model_provider import get_model
raw_model = get_model(name="resnestabc14", pretrained=True)
# First case
input_tensor = Input(shape=(224, 224, 3), batch_size=64)
output_tensor = raw_model(input_tensor)
model = Model(inputs=input_tensor, outputs=output_tensor)
# Second case
input_tensor = Input(shape=(224, 224, 3))
output_tensor = raw_model(input_tensor)
model = Model(inputs=input_tensor, outputs=output_tensor)
The first case runs properly, while the second case crashes.
All the best.
from imgclsmob.
Could you show me a minimal script to reproduce the error?
from imgclsmob.
WARNING:tensorflow:Skipping loading of weights for layer output1 due to mismatch in shape ((2048, 5) vs (2048, 1000)).
WARNING:tensorflow:Skipping loading of weights for layer output1 due to mismatch in shape ((5,) vs (1000,)).
INFO:tensorflow:Error reported to Coordinator: in user code:
TypeError: in user code:
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\training.py:571 train_function *
outputs = self.distribute_strategy.run(
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\resnesta.py:314 call *
x = self.features(x, training=training)
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\common.py:2925 call *
x = block(x, training=training)
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\common.py:2925 call *
x = block(x, training=training)
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\resnesta.py:234 call *
x = self.body(x, training=training)
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\resnesta.py:131 call *
x = self.conv2(x, training=training)
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\common.py:2739 call *
x = self.att(x, training=training)
C:\ProgramData\Anaconda3\lib\site-packages\tf2cv\models\common.py:2624 call *
x = tf.reshape(x, shape=(batch, height, width, self.radix, channels // self.radix))
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py:193 reshape **
result = gen_array_ops.reshape(tensor, shape, name)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py:8087 reshape
"Reshape", tensor=tensor, shape=shape, name=name)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:473 _apply_op_helper
raise err
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:470 _apply_op_helper
preferred_dtype=default_dtype)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py:1341 convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py:321 _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py:262 constant
allow_broadcast=True)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\constant_op.py:300 _constant_impl
allow_broadcast=allow_broadcast))
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_util.py:547 make_tensor_proto
"supported type." % (type(values), values))
TypeError: Failed to convert object of type <class 'tuple'> to Tensor. Contents: (None, 128, 128, 2, 64). Consider casting elements to a supported type.
from imgclsmob.
minimal script:
model = tf2cv_get_model("resnesta50", pretrained=True, data_format="channels_last")
optimizer = tfa.optimizers.Lookahead(tfa.optimizers.RectifiedAdam(learning_rate=LR))
model.compile(...)
model.fit(...)
from imgclsmob.
Do you use a tf2cv
pip package? What version is it?
Are you training other models with the same script?
from imgclsmob.
Is the latest version
Default used in the last 2-3 days pip install tf2cv
from imgclsmob.
Sorry. I can't reproduce your case using this description. It could be because of the different versions of TF/Keras or because I doesn't train the net with the fit
function. I could suggest the following course of action: Please make a private repository containing minimal working code that reproduces the bug. In the readme, describe where to download the dataset. Add me to the repository. I'll debug the code and localize the error.
from imgclsmob.
I'll try another version TF/Keras.Which version of TF / keras is suitable for this model library?
from imgclsmob.
Theoretically any. Now I have TF 2.4.0 and Keras 2.3.1.
from imgclsmob.
Please test the effect of the last commit in the repository.
from imgclsmob.
thanks
from imgclsmob.
Thanks for the quick patch. The updated code works as expected.
from imgclsmob.
Related Issues (20)
- API
- Inplace RunError when testing backward of RevNet with PyTorch 1.11.0 HOT 1
- [PyTorch] simplepose_resnet18_coco model weights loading error
- [Pytorch] Could you provide the hyper-parameters for the model training on Pascal VOC dataset?
- Adding new SOTA backbones
- Issue while using seresnet HOT 1
- demo_pt.py failed on ICNet HOT 4
- Error in PSPBlock while running inference with ICNet HOT 2
- Problem when loading CGNet HOT 3
- Looking forward to the <nfnets> researched by deepmind
- 'seresnext50_32x4d' pytorch RuntimeError: Given input size: (2048x4x4). Calculated output size: (2048x-2x-2). Output size is too small HOT 1
- Multiple outputs using PSPNet pre-trained model on Cityscapes HOT 7
- VoVNet27s Model Weights Missing HOT 1
- Performance issues in your project (by P3) HOT 1
- Visual Transformers?
- VGG models for cifar
- pytorchcv in_size argument
- PyramidNet maybe wrong.
- Support the XDG Base Directory Specification
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgclsmob.