I have a network for semantic segmentation and the last layer of my model applies a sigmoid activation, so all predictions are scaled between 0-1. There is this validation metric tf.keras.metrics.MeanIoU(num_classes), which compares classified predictions (0 or 1) with validation (0 or 1). So if i make a prediction and apply this metric, will it automatically map the continuous predictions to binary with threshold = 0.5? Are there any possibilities to manually define the threshold?
tf.keras.metrics.MeanIoU with sigmoid layer
3.4k views Asked by WillemBoone At
2
There are 2 answers
0
刘亚龙
On
Try this(remember to replace the space with tab):
def mean_iou(y_true, y_pred):
th = 0.5
y_pred_ = tf.to_int32(y_pred > th)
score, up_opt = tf.metrics.mean_iou(y_true, y_pred_, 2)
K.get_session().run(tf.local_variables_initializer())
with tf.control_dependencies([up_opt]):
score = tf.identity(score)
return score
Related Questions in VALIDATION
- Terraform valdiate that one of N variables is set to "true"
- How to validate if Confirm Password is same or not with the Password in React Native using ValidateJS?
- How to create yup schema for dynamic array of different objects
- Quintic Number Number Counting Hash Function
- DropdownButtonFormField doesn't apply custom InputDecoration style
- Is there a way to set a cells value based on the value this cell held at a certain time, even when the cell value changes over time?
- Multiple regex expressions to check mobile number in javascript
- Java Pojos - Setter-Call (Field Touched) Detection
- Input Field Required
- Angular restore ngModel input field to it's previous value
- Bean Validaton : org.springframework.web.bind.MethodArgumentNotValidException
- javax validation not working on spring boot
- How to show warning message for unmatched confirm password
- Flutter TextFormField validation with Firestore
- eval_set in CatBoostRegressor
Related Questions in BINARY
- ELF binary has inconsistency detected by ld.so: dl-call-libc-early-init.c: 37: Assertion `sym != NULL' failed
- How to only estimate neonatal mortality using syncmrates in Stata?
- change binary data like "111 into 001" in python by using if else or using regex
- Error in eval(predvars, data, env) : object 'Juice_practice' not found when running binary logistic regression in r
- How to subtract large binary numbers?
- How to convert n most significant bits in a hexadecimal byte string in Python 3
- Is it possible to represent -3/32 as a binary floating-point value using only 7 bits
- how to copy binary files to the worker nodes on Databricks?
- Decimal to Binary program not working on my local machine but works perfectly on online compiler
- After saving to txt file all of the data is corrupted
- Reading .bson file with Rust
- Why won't my binary search work for numbers that are double digits?
- MIPS Aiken to Binary
- Minimizing the number of basic arithmetic/binary operators needed to arrive at all others
- Resnet50 for binary classification predicts all the images to be of the same class
Related Questions in TF.KERAS
- unable to use ignore_class in SparseCategoricalCrossentropy
- The kernel appears to have died. It will restart automatically. whenever i try to run the plt.imshow() and plt.show() function in jupyter notebook
- AttributeError: module 'keras._tf_keras.keras.layers' has no attribute 'experimental'
- Keras TensorFlow Probability model not learning distribution spread
- Error Encountered: InvalidArgumentError: Graph execution error using Keras and Transformers
- I have trained an image classifier using Tensorflow, but while loading its weights afterwards, I get an error
- AttributeError: module 'keras._tf_keras.keras' has no attribute '__internal__'
- How can I correct an input_shape error produced when following the "Overfit and underfit" TensorFlow tutorial?
- Understanding output of model.get_weights() in Keras
- Keras issue with layers compability
- I want to generate grad cams from images in tensorflow
- My tensorflow.keras imports are not working and I'm not sure why
- Better way of handling a .weights.h5 content in a response
- Problem facing with "keras" is not a known member of module "tensorflow"PylancereportAttributeAccessIssue
- TensorFlow .predict memory leak
Related Questions in SIGMOID
- How do you design a feedforward sigmoidal neural network in simulink in order to find a universal approximator
- Modeling Sigmoid Curve with Time-Dependent Steepness in Python
- My one neuron neural network does not work with my dataset
- ValueError: Input 0 of layer "sequential_17" is incompatible with the layer: expected shape=(None, 6), found shape=(None, 5)
- Transferring function from Desmos to Excel: Error due to SQRT(-ve) number
- Implementation of sigmoid function as input in simulink
- Why my plot cannot show sigmoid graph? Whereas I already input to the function
- What Is the importance of using Relu?
- Parameters that denote the dynamic range, symmetry and slope of the sigmoid function respectively in software WEKA
- Why my tensorflow model is not learning in logistic regression - binary classification problem?
- Positive class in keras binary classification report has a F1 score of zero even if flatten() is used
- Two neural networks - combine sigmoid outputs
- Curve fit and extrapolate for sigmoid function in Python
- Neural network with sigmoid function always get value closer to 0.5 fo XOR
- The neural network after several training epochs has too large sigmoid values and does not learn
Related Questions in KERAS-METRICS
- Why does IoU as metrics for Semantic Segmentation raise a values error in Keras?
- Why keras AUC returns zero when multi-label is set?
- How do I solve Kera's MeanIoU Confusion matrix error?
- ValueError: Shapes (None,) and (None, 1) are incompatible
- Custom metric for Keras model, using Tensorflow 2.1
- Tensorflow metrics with residual not zero during training
- tf.keras.metrics.MeanIoU with sigmoid layer
- Separating custom keras metric inputs into two seperate metrics and finding median error
- Custom keras metric with tensorflowflow functions. Uninitialized variables
- How to use False Positives metric in Tensorflow 2.0?
- Whats the output for Keras categorical_accuracy metrics?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
No,
tf.keras.metrics.MeanIoUwill not automatically map the continuous predictions to binary with threshold = 0.5.It will convert the continuous predictions to its binary, by taking the binary digit before decimal point as predictions like
0.99as0,0.50as0,0.01as0,1.99as1,1.01as1etc whennum_classes=2. So basically if your predicted values are between0to1andnum_classes=2, then everything is considered0unless the prediction is1.Below are the experiments to justify the behavior in
tensorflow version 2.2.0:All binary result :
Output -
Change one prediction to continuous 0.99 - Here it considers
0.99as0.Output -
Change one prediction to continuous 0.01 - Here it considers
0.01as0.Output -
Change one prediction to continuous 1.99 - Here it considers
1.99as1.Output -
So ideal way is to define a function to convert the continuous to binary before evaluating the
MeanIoU.Hope this answers your question. Happy Learning.