草庐IT

pywrap_tensorflow_internal

全部标签

python - 在TensorFlow中,变量名称中的 ":0"是什么意思?

importtensorflowastfwithtf.device('/gpu:0'):foo=tf.Variable(1,name='foo')assertfoo.name=="foo:0"withtf.device('/gpu:1'):bar=tf.Variable(1,name='bar')assertbar.name=="bar:0"上面的代码返回true。我这里用withtf.device来说明“:0”并不代表变量位于特定的设备上。那么“”是什么意思:0"在变量名中(本例中为foo和bar)? 最佳答案 这与底层API中张

python - 带有 bool 张量的 tensorflow 索引

在numpy中,有两个相同形状的数组x和y,可以像这样y[x>1]。您如何在tensorflow中获得相同的结果?y[tf.greater(x,1)]不起作用,tf.slice也不支持这样的东西。现在有没有办法使用bool张量进行索引,还是目前不受支持? 最佳答案 试试:ones=tf.ones_like(x)#createatensorallonesmask=tf.greater(x,ones)#booleantensor,mask[i]=Trueiffx[i]>1slice_y_greater_than_one=tf.boole

python - 在 tensorflow 中输入图像数据以进行迁移学习

我正在尝试使用tensorflow进行迁移学习。我从教程中下载了预训练模型inception3。在代码中,用于预测:prediction=sess.run(softmax_tensor,{'DecodeJpeg/contents:0'}:image_data})有没有办法提供png图像。我尝试将DecodeJpeg更改为DecodePng但它不起作用。另外,如果我想提供解码后的图像文件,如numpy数组或一批数组,我应该改变什么?谢谢!! 最佳答案 classify_image.py中使用的InceptionV3图仅支持开箱即用的J

python - TensorFlow:使用一个张量来索引另一个张量

我有一个关于如何在TensorFlow中进行索引的基本问题。在numpy中:x=np.asarray([1,2,3,3,2,5,6,7,1,3])e=np.asarray([0,1,0,1,1,1,0,1])#numpyprintx*e[x]我可以得到[1033050713]如何在TensorFlow中做到这一点?x=np.asarray([1,2,3,3,2,5,6,7,1,3])e=np.asarray([0,1,0,1,1,1,0,1])x_t=tf.constant(x)e_t=tf.constant(e)withtf.Session():????谢谢!

python - 什么是 tensorflow.compat.as_str()?

在Google/UdemyTensorflowtutorial有如下代码:importtensorflowastf...defread_data(filename):"""Extractthefirstfileenclosedinazipfileasalistofwords"""withzipfile.ZipFile(filename)asf:data=tf.compat.as_str(f.read(f.namelist()[0])).split()returndata这执行得很好,但我在Tensorflow文档或其他任何地方都找不到compat.as_str。Q1:compat.as

python - 是否可以修改现有的 TensorFlow 计算图?

TensorFlow图通常从输入到输出逐渐构建,然后执行。查看Python代码,操作的输入列表是不可变的,这表明不应修改输入。这是否意味着无法更新/修改现有图表? 最佳答案 TensorFlowtf.Graphclass是一个append-only数据结构,这意味着您可以在执行完部分图后将节点添加到图中,但不能删除或修改现有节点。因为当你调用Session.run()时TensorFlow只执行必要的子图。,在图中有冗余节点没有执行时间成本(尽管它们会继续消耗内存)。要删除图表中的所有个节点,您可以使用新图表创建session:wi

python - TensorFlow - 'split_dim' Op 的输入 'Split' 的 float32 类型与预期的 int32 类型不匹配

我在ubuntu16.04LTS上使用pip安装了tensorflow,运行此代码时https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/recurrent_network.py我收到此错误Successfullydownloadedtrain-images-idx3-ubyte.gz9912422bytes.Extracting/tmp/data/train-images-idx3-ubyte.gzSuccessfullydownloadedtrain-la

python - 如何优化推理一个简单的、保存的 TensorFlow 1.0.1 图?

我无法在已保存的简单TensorFlow图(Python2.7;由pipinstalltensorflow-gpu==1.0.1安装的软件包)上成功运行optimize_for_inference模块。背景保存TensorFlowGraph这是我的Python脚本,用于生成并保存一个简单的图形,以将5添加到我的输入xplaceholder操作。importtensorflowastf#makeandsaveasimplegraphG=tf.Graph()withG.as_default():x=tf.placeholder(dtype=tf.float32,shape=(),name=

python - reduce_sum() 在 tensorflow 中是如何工作的?

我正在学习tensorflow,我从tensorflow网站上拿起了以下代码。根据我的理解,axis=0代表行,axis=1代表列。他们如何获得评论中提到的输出?我已经根据我对##的想法提到了输出。importtensorflowastfx=tf.constant([[1,1,1],[1,1,1]])tf.reduce_sum(x,0)#[2,2,2]##[3,3]tf.reduce_sum(x,1)#[3,3]##[2,2,2]tf.reduce_sum(x,[0,1])#6##Didn'tunderstandatall. 最佳答案

python - uWSGI 中的 Flask 仅因导入 SQLAlchemy 而导致 500 Internal Server Error

TL;DR编辑:我没有设置正确的文件夹权限。当我通过sourcevenv/bin/activate&&pythonrun.py运行flask时,一切正常。fromflaskimportFlaskfromflask.ext.sqlalchemyimportSQLAlchemyapp=Flask(__name__)@app.route("/")defhello():return"Hello,world!"if__name__=="__main__":app.debug=Trueapp.run(host='0.0.0.0',port=8080)但是当我使用nginx/emperor.uwsg