我发现了最自定义的指标。
smooth = 0.001
dices = (2. * a + smooth) / (a+ b+ smooth)
ratio = a/ (K.sum(a) + smooth)
ratio = 1.0 - ratio
为什么作者更喜欢浮点数(例如2.
和1.0
)而不是整数(2
或1
)?我发现很多人更喜欢使用浮点数而不是整数,但我不知道为什么。
我猜是否是this是原因?
下面的代码将显示两者之间的区别。
t1 = tf.constant(value=1)
t1.dtype
输出tf.int32
t2 = tf.constant(value=1.0)
t2.dtype
输出tf.float32
现在添加这两个张量将引发错误,因为这两个张量的数据类型不同。
t3 = tf.add(x=t1, y=t2)
输出:
追踪(最近通话):_apply_op_helper中的第527行的文件“ c:\ ProgramData \ Anaconda3 \ envs \ tensorflow_cpu \ lib \ site-packages \ tensorflow \ python \ framework \ op_def_library.py”preferred_dtype = default_dtype)文件“ c:\ ProgramData \ Anaconda3 \ envs \ tensorflow_cpu \ lib \ site-packages \ tensorflow \ python \ framework \ ops.py”,行1224,位于internal_convert_to_tensor中ret = conversion_func(值,dtype = dtype,名称=名称,as_ref = as_ref)_TensorTensorConversionFunction中的文件``c:\ ProgramData \ Anaconda3 \ envs \ tensorflow_cpu \ lib \ site-packages \ tensorflow \ python \ framework \ ops.py'',行1018(dtype.name,t.dtype.name,str(t)))ValueError:张量转换请求的dtype float32的张量为dtype int32:'Tensor(“ Const_4:0”,shape =(),dtype = float32)'