tf.atan()

tf.atan()计算arctanx的值
参数:

tf.atan(
    x, 
    name=None
)

使用案例:

import tensorflow as tf

x = tf.atan(0.0)
sess = tf.Session()
print(sess.run(x)) #0.0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
详细解释这段代码:def phsical_loss(y_true, y_pred): y_true =tf.cast(y_true, y_pred.dtype) loss_real=tf.keras.losses.MSE(y_true[0],y_pred[0]) loss_img= tf.keras.losses.MSE(y_true[1],y_pred[1]) amp_ture=tf.pow(y_true[0],2)+tf.pow(y_true[1],2) amp_pred=tf.pow(y_pred[0],2)+tf.pow(y_pred[1],2) loss_amp=tf.keras.losses.MSE(amp_ture,amp_pred) return loss_real+loss_img+loss_amp#两个子模型各加一个完整约束 def angle_loss(y_true, y_pred): y_true = tf.cast(y_true, y_pred.dtype) img_ture=tf.atan2(y_true[1],y_true[0]) img_pred=tf.atan2(y_pred[1],y_pred[0]) return tf.keras.losses.MAE(img_ture,img_pred) def amp_loss(y_true, y_pred): y_true = tf.cast(y_true, y_pred.dtype) amp_ture=tf.pow(y_true[0],2)+tf.pow(y_true[1],2) amp_pred=tf.pow(y_pred[0],2)+tf.pow(y_pred[1],2) loss_phsical=tf.keras.losses.MSE(amp_ture,amp_pred) return loss_phsical model_in=tf.keras.Input((16,16,1)) model_real_out=ResNet18([2,2,2,2])(model_in) model_img_out=ResNet18([2,2,2,2])(model_in) model_all=tf.keras.Model(model_in,[model_real_out,model_img_out]) model_all.compile(loss=phsical_loss, optimizer=tf.keras.optimizers.Adam(tf.keras.optimizers.schedules.InverseTimeDecay( 0.001, decay_steps=250*25, decay_rate=1, staircase=False)), metrics=['mse']) checkpoint_save_path= "C:\\Users\\Root\\Desktop\\bysj\\model_all.ckpt" if os.path.exists(checkpoint_save_path + '.index'): print('------------------load model all---------------------') model_all.load_weights(checkpoint_save_path) cp_callback = tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_save_path, save_weights_only=True,save_best_only=True)
最新发布
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值