Skip to content

AttributeError: module 'keras.backend' has no attribute 'sum' #76

Description

@aggarwalstuti

After entering the following code:
metrics=['accuracy', jacard_coef]

def get_model():
return multi_unet_model(n_classes=n_classes, IMG_HEIGHT=IMG_HEIGHT, IMG_WIDTH=IMG_WIDTH, IMG_CHANNELS=IMG_CHANNELS)

model = get_model()
model.compile(optimizer='adam', loss=total_loss, metrics=metrics)
#model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=metrics)
model.summary()

history1 = model.fit(X_train, y_train,
batch_size = 16,
verbose=1,
epochs=100,
validation_data=(X_test, y_test),
shuffle=False)

I am encountering the following error:
Total params: 1,941,190 (7.41 MB)
Trainable params: 1,941,190 (7.41 MB)
Non-trainable params: 0 (0.00 B)
Epoch 1/100

AttributeError Traceback (most recent call last)
in <cell line: 12>()
10
11
---> 12 history1 = model.fit(X_train, y_train,
13 batch_size = 16,
14 verbose=1,

3 frames
/usr/local/lib/python3.10/dist-packages/segmentation_models/base/functional.py in f_score(gt, pr, beta, class_weights, class_indexes, smooth, per_image, threshold, **kwargs)
143
144 # calculate score
--> 145 tp = backend.sum(gt * pr, axis=axes)
146 fp = backend.sum(pr, axis=axes) - tp
147 fn = backend.sum(gt, axis=axes) - tp

AttributeError: module 'keras.backend' has no attribute 'sum'

I am using keras Version: 3.0.2 and for tensorflow Version: 2.15.0.post1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions