Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When trying to train FasterRCnn network get an error TypeError if the batch size is not specified. #2503

Open
odinsbane opened this issue Nov 8, 2024 · 1 comment
Assignees
Labels
type:Bug Something isn't working

Comments

@odinsbane
Copy link

odinsbane commented Nov 8, 2024

When I attempt train an FasterRCNN network I get the follow error if the batch size is not specified.

TypeError: Expected int32 passed to parameter 'y' of op 'Mul', got 0.25 of type 'float' instead. Error: Expected int32, but got 0.25 of type 'float'.

Expected Behavior:

The network should begin training.

Steps To Reproduce:

import keras_cv, keras, numpy

if __name__=="__main__":
    backbone = keras_cv.models.ResNet50V2Backbone(input_shape=(64, 64, 3))
    model = keras_cv.models.FasterRCNN( backbone, 1,  "xyxy", num_max_decoder_detections=128)
    model.compile(
        box_loss="Huber",
        rpn_classification_loss = keras.losses.BinaryCrossentropy(from_logits=True),
        rpn_box_loss = "Huber",
        optimizer=keras.optimizers.Adam(learning_rate=1e-6),
        classification_loss=keras.losses.BinaryCrossentropy(from_logits=True),
    )
    images = numpy.random.random( (8, 64, 64, 3) )
    boxes = numpy.random.random( (8, 8, 4) )
    classes = numpy.random.random( (8, 8) )
    
    model.fit(images, {"boxes":boxes, "classes" : classes})

Work around:

Specify the batch_size when calling fit and the program runs fine.

Version:

keras-cv-nightly==0.10.0.dev2024100303

@sachinprasadhs
Copy link
Collaborator

@sineeli

@sachinprasadhs sachinprasadhs added the type:Bug Something isn't working label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants