Answer to Question #257964 in Software Engineering for Nitish

Question #257964

Calculate the output y of a three input neuron with bias. The input feature vector is (x1, x2, x3) = (0.6,0.4,0.2) and weight values are [w1,w2,w3, b]=[0.2, 0.1, -0.4, 0.37]. Use binary Sigmoid function as activation function.


1
Expert's answer
2021-11-04T16:26:56-0400
def binary_crossentropy(target, output, from_logits=False):
	    """Binary crossentropy between an output tensor and a target tensor.
	
	    # Arguments
	        target: A tensor with the same shape as `output`.
	        output: A tensor.
	        from_logits: Whether `output` is expected to be a logits tensor.
	            By default, we consider that `output`
	            encodes a probability distribution.
	
	    # Returns
	        A tensor.
	    """
	    # Note: tf.nn.sigmoid_cross_entropy_with_logits
	    # expects logits, Keras expects probabilities.
	    if not from_logits:
	        # transform back to logits
	        _epsilon = _to_tensor(epsilon(), output.dtype.base_dtype)
	        output = tf.clip_by_value(output, _epsilon, 1 - _epsilon)
	        output = tf.log(output / (1 - output))
	

	    return tf.nn.sigmoid_cross_entropy_with_logits(labels=target,
	                                                   logits=output)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS