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

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

Open
aggarwalstuti opened this issue Dec 29, 2023 · 1 comment
Open

Comments

@aggarwalstuti
Copy link

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

@AhabbscienceStudioPak
Copy link

You need to use keras version 2 and an older version of segmentation mask 3d library that supports keras 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants