tensorflow

PyTorch equivalence for softmax_cross_entropy_with_logits

时间秒杀一切 提交于 2021-01-26 03:48:38
问题 I was wondering if there is an equivalent loss function in PyTorch for TensorFlow's softmax_cross_entropy_with_logits . 回答1: equivalent loss function in PyTorch for TensorFlow's softmax_cross_entropy_with_logits It is torch.nn.functional.cross_entropy It takes logits as inputs (performs log_softmax internally). In here logits are just some values that are not probabilities, outside of [0,1] interval. But, logits are also the values that will be converted to probabilities. If you consider the

Why doesn't custom training loop average loss over batch_size?

妖精的绣舞 提交于 2021-01-25 20:25:05
问题 Below code snippet is the custom training loop from Tensorflow official tutorial.https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch . Another tutorial also does not average loss over batch_size , as shown here https://www.tensorflow.org/tutorials/customization/custom_training_walkthrough Why is the loss_value not averaged over batch_size at this line loss_value = loss_fn(y_batch_train, logits) ? Is this a bug? From another question here Loss function works with reduce

Why doesn't custom training loop average loss over batch_size?

非 Y 不嫁゛ 提交于 2021-01-25 20:22:19
问题 Below code snippet is the custom training loop from Tensorflow official tutorial.https://www.tensorflow.org/guide/keras/writing_a_training_loop_from_scratch . Another tutorial also does not average loss over batch_size , as shown here https://www.tensorflow.org/tutorials/customization/custom_training_walkthrough Why is the loss_value not averaged over batch_size at this line loss_value = loss_fn(y_batch_train, logits) ? Is this a bug? From another question here Loss function works with reduce

Keras load saved model: SystemError: unknown opcode

时光毁灭记忆、已成空白 提交于 2021-01-25 17:17:09
问题 if I load a model which was saved to a tf saved model file I get the following issue. (keras 2.0) SystemError: unknown opcode As I can find this has to do with a lambda layer in my model. https://github.com/keras-team/keras/issues/9595 There was stated the solution to save the architecure and weights. Keep the code around and just save the weights. As you said: save the architecture as code, and the weights in an h5. This will be compatible across versions But how do I do that? How do I save

Keras load saved model: SystemError: unknown opcode

人走茶凉 提交于 2021-01-25 16:59:30
问题 if I load a model which was saved to a tf saved model file I get the following issue. (keras 2.0) SystemError: unknown opcode As I can find this has to do with a lambda layer in my model. https://github.com/keras-team/keras/issues/9595 There was stated the solution to save the architecure and weights. Keep the code around and just save the weights. As you said: save the architecture as code, and the weights in an h5. This will be compatible across versions But how do I do that? How do I save

我又一次被 Google Developer Day 给丑拒了!

余生颓废 提交于 2021-01-25 13:17:48
2018 Google开发者大会为期两天,将于9月20日和 21日在上海举办,主题将涵盖机器学习、ARCore、Android、Play、WearOS、无障碍、移动网络、Firebase、Assistant、物联网、云服务、Flutter、设计、广告和商业应用等等。 2018谷歌开发者大会的今天报名结果已经揭晓了,官方已经把 所有报名结果均已发送至报名邮箱 ,请查收确认。若未在收件箱收到邮件,请查看垃圾邮件箱或其他邮件组。 报名成功的小伙伴,请根据邮件信息准时参与活动 ,聆听最新技术演讲分享,参与好玩的现场体验,收获定制惊喜礼物,亲身享受这场热闹非凡的谷歌技术盛宴! (其实说白了就是去白吃白喝的)。 参加会议的朋友们除了想了解下Google最前沿的技术外,有一部分观众,除了抱着面基的想法,甚至来上海玩玩的打算,但是结果几家欢喜几家愁啊。 很多人被丑拒了: 当然我是不可能被丑拒的: 不过我是通过公司名额去的,也不会被扣工资。 其实早在 8月14号晚上就收到了参加报名的链接就可以报名了,官方是15号才公开报名渠道的。 审核通过的9月3号开始已经发了邮件。 我总结了一些通过率高的人回答,总结下面几点,能提高通过的概率。 1 不要写自己是Android, 要写iOS,或者其他语言行业。 2 用Google邮箱 3 学校填写名校,名企。 4 提前注册开发者账号。 5 对Google

「ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory」

早过忘川 提交于 2021-01-25 07:45:32
tensorflow版本和cuda,cudnn版本的兼容性问题。 参考以下博客: 「 https://blog.csdn.net/qq_18649781/article/details/89045243 」 「 https://blog.csdn.net/omodao1/article/details/83241074 」「tensorflow版本和cuda,cudnn版本的兼容表格」 【给Ubuntu装上xrdp的远程桌面之后,远程登陆以后发现无法调用之前给主机安装的tensorflow,出现了一样的报错】 【排查了,不是版本问题,而是ldconfig的库地址环境变量问题?】 sudo ldconfig /usr/local/cuda- 9.0 /lib64 【参考】 【 https://blog.csdn.net/eb_num/article/details/89602652 】【使用ldconfig命令】 【 https://blog.csdn.net/winycg/article/details/80572735 】【关于ldconfig命令的作用】 来源: oschina 链接: https://my.oschina.net/u/4397772/blog/3517735

How to get Graph (or GraphDef) from a given Model?

旧街凉风 提交于 2021-01-24 14:52:46
问题 I have a big model defined using Tensorflow 2 with Keras. The model works well in Python. Now, I want to import it into C++ project. Inside my C++ project, I use TF_GraphImportGraphDef function. It works well if I prepare *.pb file using the following code: with open('load_model.pb', 'wb') as f: f.write(tf.compat.v1.get_default_graph().as_graph_def().SerializeToString()) I've tried this code on a simple network written using Tensorflow 1 (using tf.compat.v1.* functions). It works well. Now I

TypeError: __init__() missing 1 required positional argument: 'units'

半城伤御伤魂 提交于 2021-01-24 11:39:11
问题 I am working in python and tensor flow but I miss 'units' argument and I do not know how to solve it, It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details. here the code def createModel(): model = Sequential() # first set of CONV => RELU => MAX POOL layers model.add(Conv2D(32, (3, 3), padding='same', activation='relu', input_shape=inputShape)) model.add(Conv2D(32, (3, 3), activation='relu')) model.add

TypeError: __init__() missing 1 required positional argument: 'units'

[亡魂溺海] 提交于 2021-01-24 11:37:40
问题 I am working in python and tensor flow but I miss 'units' argument and I do not know how to solve it, It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details. here the code def createModel(): model = Sequential() # first set of CONV => RELU => MAX POOL layers model.add(Conv2D(32, (3, 3), padding='same', activation='relu', input_shape=inputShape)) model.add(Conv2D(32, (3, 3), activation='relu')) model.add