Skip to content

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

Open
@odinsbane

Description

@odinsbane

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions