-
tf.cast()可附加条件,例如:
#tensor大于0的元素的位置返回True,其余返回False(在dtype为bool的情况下) #其他情况同理 tf.cast(tensor>0,dtype) -
tf.where
#在predict张量和tartget张量元素在0.5两边时 #theta矩阵响应元素置1,否则置0 x=tf.ones_like(log_yi, dtype=tf.float32) y=tf.zeros_like(log_yi, dtype=tf.float32) condition = ((target - 0.5) * (predict - 0.5)<0.) theta = tf.where(condition,x,y) -
evaluation_hook可以使用tf.train里面的hookevaluation_hook = tf.train.LoggingTensorHook({"total_loss:": total_loss}, every_n_iter=10) output_spec = tf.contrib.tpu.TPUEstimatorSpec( mode=mode, loss=total_loss, eval_metrics=eval_metrics, scaffold_fn=scaffold_fn, evaluation_hooks=[evaluation_hook])#12345是传入的seed,用来选定第一次random的开始点 random.Random(12345) rng.shuffle(train_examples)
tensorflow慢慢积累的小知识点
最新推荐文章于 2025-06-24 00:27:25 发布
本文探讨了TensorFlow中tf.cast(), tf.where()等函数的高级应用,包括条件转换和矩阵元素选择。同时,深入讲解了如何利用tf.train.LoggingTensorHook进行模型训练状态的监控,并在TPUEstimatorSpec中配置评估hook。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
TensorFlow-v2.15
TensorFlow
TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型
1232

被折叠的 条评论
为什么被折叠?



