草庐IT

KTruPWrYO9WFj-TF

全部标签

python - GPU 上的 tf.reduce_sum 结合占位符作为输入形状失败

更新:在Tensorflow1.14.0中修复(可能更早,没有检查)更新:仍在Tensorflow1.7.0中发生更新:我写了一个协作笔记本,在google的gpu硬件上重现了这个bug:https://drive.google.com/file/d/13V87kSTyyFVMM7NoJNk9QTsCYS7FRbyz/view?usp=sharing更新:在这个问题的第一个修订版中错误地指责tf.gather之后,我现在将其缩小到tf.reduce_sum并结合占位符作为形状:tf.reduce_sum为形状取决于占位符的大张量生成零(仅在GPU上)。在向占位符batch_size(在

python - 使用 tf.estimator 提前停止,如何?

我在TensorFlow1.4中使用tf.estimator并且tf.estimator.train_and_evaluate很棒,但我需要尽早停止。添加它的首选方式是什么?我假设在某处有一些tf.train.SessionRunHook。我看到有一个带有ValidationMonitor的旧contrib包似乎提前停止,但在1.4中似乎不再存在。或者将来首选的方式是依赖tf.keras(提前停止真的很容易)而不是tf.estimator/tf.layers/tf.data,也许? 最佳答案 好消息!tf.estimator现在对m

python - TensorFlow AttributeError : 'NoneType' object has no attribute 'TF_DeleteStatus'

Tensorflow给了我这个Unresolved错误:Exceptionignoredin:>Traceback(mostrecentcalllast):File"/opt/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py",line532,in__del__AttributeError:'NoneType'objecthasnoattribute'TF_DeleteStatus'错误已讨论here.问题是它没有始终如一地出现。但是,它经常出现在我的终端中。有没有人设法绕过它。谢谢。

python - 如何在 Tensorflow 中从 tf.keras 导入 keras?

importtensorflowastfimporttensorflowfromtensorflowimportkerasfromkeras.layersimportDense我收到以下错误fromkeras.layersimportInput,DenseTraceback(mostrecentcalllast):File"",line1,infromkeras.layersimportInput,DenseModuleNotFoundError:Nomodulenamed'keras'我该如何解决这个问题?注意:我使用的是Tensorflow1.4版 最佳

python - tf.gfile 在 TensorFlow 中做了什么?

我见过有人使用tf.gfile中的几个函数,例如tf.gfile.GFile或tf.gfile.Exists。我的想法是tf.gfile处理文件。但是,我无法找到官方文档来查看它还提供了什么。如果你能帮我解决,那就太好了。 最佳答案 对于登陆这里的任何人,以下答案(由googler提供):Whyusetensorflowgfile?(forfileI/O)Themainrolesofthetf.gfilemoduleare:ToprovideanAPIthatisclosetoPython'sfileobjects,andTopro

python - tf.nn.conv2d vs tf.layers.conv2d

在tf.nn.*上使用tf.layers.*?是否有任何优势例如,文档中的大多数示例使用tf.nn.conv2d,但尚不清楚他们为什么这样做。 最佳答案 正如GBY提到的,他们使用相同的实现。参数有轻微的差异。用于tf.nn.conv2d:filter:ATensor.Musthavethesametypeasinput.A4-Dtensorofshape[filter_height,filter_width,in_channels,out_channels]fortf.layers.conv2d:filters:Integer,t

python - python中的N-gram,TF-IDF和余弦相似性的简单实现

我需要比较存储在DB中的文档,并提出0到1之间的相似性分数。我需要使用的方法必须非常简单。实现N-grams的Vanilla版(在其中可以定义要使用多少克),以及简单的TF-IDF和余弦相似性的实现。是否有任何程序可以这样做?还是我应该从头开始写这篇文章? 最佳答案 查看NLTK软件包:http://www.nltk.org它具有您需要的一切cosine_simarlity:defcosine_distance(u,v):"""Returnsthecosineoftheanglebetweenvectorsvandu.Thisise

python - 在 TensorFlow 中,tf.identity 有什么用?

我在一些地方看到了tf.identity,例如官方CIFAR-10教程和stackoverflow上的批量标准化实现,但我不明白为什么它是必要的。它是做什么用的?谁能给出一两个用例?一个建议的答案是它可以用于CPU和GPU之间的传输。这对我来说不是很清楚。问题的扩展,基于this:loss=tower_loss(scope)在GPUblock下,这表明tower_loss中定义的所有算子都映射到GPU。然后,在tower_loss的末尾,我们在返回之前看到total_loss=tf.identity(total_loss)。为什么?在这里不使用tf.identity会有什么缺陷?

python - np.mean 和 tf.reduce_mean 有什么区别?

在MNISTbeginnertutorial中,有语句accuracy=tf.reduce_mean(tf.cast(correct_prediction,"float"))tf.cast基本上改变了对象的张量类型,但是tf.reduce_mean和np.mean有什么区别呢?这是tf.reduce_mean上的文档:reduce_mean(input_tensor,reduction_indices=None,keep_dims=False,name=None)input_tensor:Thetensortoreduce.Shouldhavenumerictype.reduction

python - tf.app.run() 是如何工作的?

tf.app.run()如何在Tensorflow翻译演示中工作?在tensorflow/models/rnn/translate/translate.py中,有一个对tf.app.run()的调用。它是如何处理的?if__name__=="__main__":tf.app.run() 最佳答案 if__name__=="__main__":表示当前文件在shell下执行,而不是作为模块导入。tf.app.run()你可以通过文件app.py看到defrun(main=None,argv=None):"""Runstheprogra