
tensorflow
phoebus_si
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
ValueError: Tried to convert 'g' to a tensor and failed. Error: None values not supported多卡GPU调用代码报错
def average_gradients(tower_grads): average_grads=[] for grad_and_vars in zip(*tower_grads): grads=[] for g, _ in grad_and_vars: expend_g=tf.expand_dims(g,0) ...原创 2020-02-03 22:57:34 · 7654 阅读 · 4 评论 -
tf.cond报错Initializer for variable is from inside control-flow construct such as a loop or condition
完整报错信息:ValueError: Initializer for variable lambda_5/cond/mrcnn_mask_conv1/kernel/ is from inside a control-flow construct, such as a loop or conditional. When creating a variable inside a loop or con...原创 2019-11-16 23:45:55 · 1269 阅读 · 1 评论 -
typeError: Cannot interpret feed_dict key as Tensor: Can not convert a Int into a Tensor
报错信息:TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a int into a Tensor报错代码: [s, t, c] = sess.run([ lstm.s, lstm.t, lstm.c], feed_dict={lstm.i...原创 2019-07-29 23:35:44 · 4411 阅读 · 1 评论 -
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_11' with dtype float
报错信息:InvalidArgumentError:Youmustfeedavalueforplaceholdertensor'Placeholder_11'withdtypedoubleandshape[3,300]报错代码: [s, t, c] = sess.run([ lstm.s, lstm.t, lstm.c],...原创 2019-07-29 23:31:08 · 2089 阅读 · 0 评论 -
Could not install packages due to an EnvironmentError: pip install 安装时遇到环境错误的解决办法
具体报错 Found existing installation: setuptools 18.5 Uninstalling setuptools-18.5:Could not install packages due to an EnvironmentError: [('/System/Library/Frameworks/Python.framework/Versions/2....原创 2019-06-19 19:05:53 · 3097 阅读 · 0 评论 -
Keras显示召回率(classification metrics can't handle a mix of multi-label-indicator targets) model.predict
本来程序中用了model.evaluate来求loss和准确率score, acc = model.evaluate(X_test, y_test, batch_size=batch_size)后来想加上recall,查了半天也没找到model.evaluate能返回recall。后来就想换个函数:y_pred=model.predict(X_test, batch_size=...原创 2019-05-15 19:54:42 · 47651 阅读 · 23 评论 -
VAE手写体识别项目实现(详细注释)从小项目通俗理解变分自编码器(Variational Autoencoder, VAE)tu
项目及代码来源:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/variational_autoencoder.py在看代码前可以简单理解vae的基本概念上,推荐一篇知乎文章:https://zhuanlan.zhihu.com/p/55557709还有...原创 2019-05-01 03:23:21 · 2656 阅读 · 2 评论 -
如何在keras构造的分类模型中将bert预训练出的句子向量(两行代码即可得出)作为一部分输入加入模型
如何在keras构造的分类模型中将bert预训练出的句子向量(两行代码即可得出)作为一部分输入加入模型分三步走:第一步:下载预训练好的bert模型并安装bert-as-service1.首先需要先下载bertgit clone https://github.com/google-research/bert.git2.然后下载好预训练好的bert模型我做的是中文分类任务,所...原创 2019-04-25 02:43:35 · 3735 阅读 · 2 评论 -
tf.reshap()和tf.tail() Contents: [Dimension(None), 1]. Consider casting elements to a supported types
在tensorflow/Keras中batch_size是变化的且构图时初始化为None而造成的Cannot convert unknown dimension (None) 或者Contents: [Dimension(None), 1]. Consider casting elements to a supported types报错的解决办法。我在Kears构图过程中中想用tf.t...原创 2019-05-04 13:07:41 · 3732 阅读 · 0 评论 -
Keras 如何增加可训练的变量作为权重weight 并给已有的layer加权
这个小问题为难了自己一天,所以fix后决定记录以下。这篇博客是按照自己发现问题到定位问题再到解决问题的顺序来记录的,如果各位大神有更好的解决办法请指出~如果想直接上手大家可以直接看最后代码。在我的项目中需要一个可训练的vector(1,hidden_num)来对一个(batch_size,hidden_num)的矩阵每一维完成点乘在代码中看,目标是完成以下操作semantic...原创 2019-05-04 12:50:40 · 14781 阅读 · 9 评论 -
InvalidArgumentError: seq_lens() > input.dims()[[Node: hidden/bidirectional_rnn/bw/ReverseSequence
报错信息:Google了一下没有找到对应的解决方案,看了bidrection_rrn源码,发现问题出现在一个tf.reverse_sequence函数中。https://www.tensorflow.org/api_docs/python/tf/reverse_sequence错误的主要原因是在对seq进行反转时,没有满足以下条件:The elements ofseq...原创 2019-03-18 16:45:15 · 1724 阅读 · 2 评论 -
tf.contrib.rnn.LSTMCell(self.u) 报错module “tf.contrib.rnn” has no attribute 'LSTMCell‘解决办法
问题:cell_fw = tf.contrib.rnn.LSTMCell(self.u)报错module “tf.contrib.rnn” has no attribute 'LSTMCell‘解决办法:更新tensorflow到最新版本即可。更新方法:先激活tensorflow环境:activate tensorflow然后cpu使用命令:pip install...原创 2019-02-23 22:59:24 · 1783 阅读 · 2 评论 -
tf.nn.embedding_lookup(...,...,,max_norm=1)报错module has no attribute 'max_norm’
问题:tf.nn.embedding_lookup(...,...,,max_norm=1)报错module “tf.nn.embedding_lookup” has no attribute 'max_norm‘解决办法:更新tensorflow到最新版本即可。解决思路:见了这个问题后我首先想去查一下tf.nn.embedding_lookup()的api,发现官方文档中确实是有...原创 2019-02-23 22:57:36 · 456 阅读 · 0 评论