import tensorflow as tf y = tf.constant([1, 2, 3, 0, 2]) y = tf.one_hot(y, depth=4) # max_label=3种 y = tf.cast(y, dtype=tf.float32) out = tf.random.normal([5, 4]) out loss1 = tf.reduce_mean(tf.square(y - out)) loss1 loss2 = tf.square(tf.norm(y - out)…