question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix for ValueError: continuous format is not supported

See original GitHub issue

in the indad/model.py line 78

the mask must be convert to int type, otherwise, it will get ValueError: continuous format is not supported

Here is the solution: I changed the mask type from float to int

pixel_labels.extend(mask.flatten().numpy().astype(int))

The initial function is like below

	def evaluate(self, test_ds: VisionDataset) -> Tuple[float, float]:
		"""Calls predict step for each test sample."""
		image_preds = []
		image_labels = []
		pixel_preds = []
		pixel_labels = []

		for sample, mask, label in tqdm(test_ds, **TQDM_PARAMS):
			z_score, fmap = self.predict(sample.unsqueeze(0))
			
			image_preds.append(z_score.numpy())
			image_labels.append(label)
			
			pixel_preds.extend(fmap.flatten().numpy())
			pixel_labels.extend(mask.flatten().numpy())
			
		image_preds = np.stack(image_preds)

		image_rocauc = roc_auc_score(image_labels, image_preds)

		pixel_rocauc = roc_auc_score(pixel_labels, pixel_preds)

		return image_rocauc, pixel_rocauc

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rvoriascommented, Aug 24, 2021

FYI, the reduced datasets are not supposed to be run with the evaluate function. You better choose just “hazelnut” or “transistor” (the data is automatically downloaded)

1reaction
rvoriascommented, Aug 24, 2021

The evaluation function comes in handy as it can give you a threshold for a certain desired recall. If you want to visualize your predictions, it’s easier to call

# get predictions
img_lvl_anom_score, pxl_lvl_anom_score = model.predict(test_ds[0].unsqueeze(0))

Or something like that. You can then use the threshold that you got from your aurocs to threshold the faulty pixels. Right now, you’ll have to extract the best threshold yourself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: continuous format is not supported - Stack Overflow
I have written a simple function where I am using the average_precision_score from scikit-learn to compute average precision. My Code: def ...
Read more >
ValueError: continuous format is not supported in ... - GitHub
If you run the following code: import numpy as np from sklearn.linear_model.ridge import RidgeClassifierCV classifier ...
Read more >
ValueError: continuous is not supported
I am working on a regression problem and building a model using Random Forest Regressor but while trying to get the accuracy I...
Read more >
Array NaN values? ValueError: continuous format is not ...
Hi, I do have this ValueError: continuous format is not supported problem again. fpr and tpr have a few hundred rows so I...
Read more >
Valueerror: Continuous Format Is Not Supported For Knn
Got continuous is not supported error in RandomForestRegressor.I'm just trying to do a simple RandomForestRegressor example.But while testing the accuracy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found