Open Pineirin opened 5 months ago
Not following a tutorial, but a quick fix for this is to change ops.pow to ops.power: https://keras.io/api/ops/numpy/#power-function
Please let me know if you need any additional information.
Can you please put full error log?
i have the same error, how can i fix?
Please let me know if you need any additional information.
Can you please put full error log?
AttributeError Traceback (most recent call last)
4 frames
/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py in error_handler(*args, **kwargs)
120 # To get the full stack trace, call:
121 # keras.config.disable_traceback_filtering()
--> 122 raise e.with_traceback(filtered_tb) from None
123 finally:
124 del filtered_tb
/usr/local/lib/python3.10/dist-packages/segmentation_models_3D/base/objects.py in call(self, gt, pr) 128 129 def call(self, gt, pr): --> 130 return self.l1(gt, pr) + self.l2(gt, pr)
/usr/local/lib/python3.10/dist-packages/segmentation_models_3D/base/objects.py in call(self, gt, pr) 116 117 def call(self, gt, pr): --> 118 return self.multiplier * self.loss(gt, pr) 119 120
/usr/local/lib/python3.10/dist-packages/segmentation_models_3D/losses.py in call(self, gt, pr) 198 199 def call(self, gt, pr): --> 200 return F.categorical_focal_loss( 201 gt, 202 pr,
/usr/local/lib/python3.10/dist-packages/segmentation_models_3D/base/functional.py in categorical_focal_loss(gt, pr, gamma, alpha, class_indexes, *kwargs) 284 285 # Calculate focal loss --> 286 loss = - gt (alpha ops.pow((1 - pr), gamma) ops.log(pr)) 287 288 return ops.mean(loss)
AttributeError: module 'keras.api.ops' has no attribute 'pow'
I am working on colab
Change in: /usr/local/lib/python3.10/dist-packages/segmentation_models_3D/base/functional.py
ops.pow -> ops.power
I did an update in repository too
I made your changes, but it s not still working. There are also other 2 lines in functional.py that use ops.pow (row 311-312).
Now i have this error:
TypeError Traceback (most recent call last)
2 frames
/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py in error_handler(*args, **kwargs)
120 # To get the full stack trace, call:
121 # keras.config.disable_traceback_filtering()
--> 122 raise e.with_traceback(filtered_tb) from None
123 finally:
124 del filtered_tb
/usr/local/lib/python3.10/dist-packages/segmentation_models_3D/metrics.py in call(self, gt, pr) 52 53 def call(self, gt, pr): ---> 54 return F.iou_score( 55 gt, 56 pr,
/usr/local/lib/python3.10/dist-packages/segmentation_models_3D/base/functional.py in iou_score(gt, pr, class_weights, class_indexes, smooth, per_image, threshold, *kwargs) 93 # score calculation 94 ---> 95 intersection = ops.sum(gt pr, axis=axes) 96 union = ops.sum(gt + pr, axis=axes) - intersection 97
TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type float64 of argument 'x'.
Thank you
Can you say which loss function you use? And which metric?
Sure!
dice_loss = sm.losses.DiceLoss(class_weights=np.array([wt0, wt1, wt2, wt3])) focal_loss = sm.losses.CategoricalFocalLoss() total_loss = dice_loss + (1 * focal_loss) metrics = ['accuracy', sm.metrics.IOUScore(threshold=0.5)]
I modified:
https://github.com/ZFTurbo/segmentation_models_3D/blob/master/training_example_torch.py
with your settings:
dice_loss = sm.losses.DiceLoss()
focal_loss = sm.losses.CategoricalFocalLoss()
total_loss = dice_loss + (1 * focal_loss)
model.compile(optimizer=optim, loss=total_loss, metrics=[sm.metrics.IOUScore])
It works for me. May be problem with backend. Which one do you use?
Greetings.
I tried using your library to perform a 3D semantic segmentation. I attempted to follow Sreeni's (https://www.youtube.com/watch?v=Dt73QWZQck4) tutorial, but I kept running into this error during the fit.
Exception has occurred: AttributeError module 'keras.api.ops' has no attribute 'pow' File "C:\Users\Pineirin\Desktop\3DCNN\3D_UNET.py", line 72, in
model.fit(
AttributeError: module 'keras.api.ops' has no attribute 'pow'
I'm using your lates version, after installing the tensorflow, keras and classification_models_3D version defined in your requirements.txt.
I also attempted to use your library myself, as i guess the problem is with the updates, using a chatbot to aid me. But I ran into exactly the same error. I'm using Windows 10 and 11.
Sorry if I'm bothering with an issue that is due to my error, but I feel that if I reach the same error from two different paths it may be an error of the library.
Please let me know if you need any additional information.