【问题标题】:tf.unstack did not work with tf 1.8 CudnnGRU tensorstf.unstack 不适用于 tf 1.8 CudnnGRU 张量
【发布时间】:2018-09-13 03:47:16
【问题描述】:

描述问题

tf.unstack 没有按预期工作。它没有将R rank 张量减少到R-1 rank 张量

tensorflow github issue list中对应issue:https://github.com/tensorflow/tensorflow/issues/22223

源代码/日志

代码:

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import tensorflow as tf
rnn_model = tf.contrib.cudnn_rnn.CudnnGRU(
        num_layers=1,
        num_units=64,
        direction='unidirectional')
rnn_model.build([3, 1, 3])
inputs=[[[1,1,1],[1,1,1],[1,1,1]]]
inputs_tensor= tf.convert_to_tensor(inputs, dtype=tf.float32)
print(tf.shape(inputs_tensor))
rnn_out, rnn_state = rnn_model(inputs_tensor)
print("rnn_state: ", rnn_state)
rnn_layers = tf.unstack(rnn_state)
print("rnn_layers", rnn_layers)

将代码粘贴到文件demo.py,然后从linux命令行运行:

$ python3.6 demo.py

输出:

Tensor("Shape:0", shape=(3,), dtype=int32)
rnn_state:  (<tf.Tensor 'cudnn_gru/CudnnRNN:1' shape=(1, ?, 64) dtype=float32>,)
rnn_layers [<tf.Tensor 'unstack:0' shape=(1, ?, 64) dtype=float32>]

rnn_layers 应该是 rnn_layers [&lt;tf.Tensor 'unstack:0' shape=(?, 64) dtype=float32&gt;]

环境细节

我是否编写了自定义代码(而不是使用 TensorFlow 中提供的股票示例脚本):

是的

操作系统平台和发行版(例如,Linux Ubuntu 16.04):

$uname -r
3.10.0-327.el7.x86_64

移动设备:

非移动

TensorFlow 安装自(源代码或二进制文件):

anaconda tf 1.8

TensorFlow 版本(使用下面的命令):

$conda list|grep tensor
tensorboard               1.8.0            py36hf484d3e_0
tensorflow                1.8.0                hb381393_0
tensorflow-base           1.8.0            py36h4df133c_0
tensorflow-gpu            1.8.0                h7b35bdc_0

Python 版本:

$python3.6 -V
Python 3.6.2 :: Continuum Analytics, Inc.

Bazel 版本(如果从源代码编译):

$bazel version
Build label: 0.4.5
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Mar 16 12:19:38 2017 (1489666778)
Build timestamp: 1489666778
Build timestamp as int: 1489666778

CUDA/cuDNN 版本:

$conda list|grep -i cuda
cudatoolkit               8.0                           3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
cudnn                     7.0.5                 cuda8.0_0

GPU 型号和内存:

== cat /etc/issue ===============================================
Linux rvab01298.sqa.ztt 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
VERSION="7.2 (Paladin)"
VERSION_ID="7.2"
qihoo360_BUGZILLA_PRODUCT_VERSION=7.2
qihoo360_SUPPORT_PRODUCT_VERSION=7.2

== are we in docker =============================================
No

== compiler =====================================================
c++ (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


== uname -a =====================================================
Linux rvab01298.sqa.ztt 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

== check pips ===================================================
numpy (1.13.3)
protobuf (3.5.1)
tensorflow (1.8.0)

== check for virtualenv =========================================
False

== tensorflow import ============================================
tf.VERSION = 1.8.0
tf.GIT_VERSION = b'unknown'
tf.COMPILER_VERSION = b'unknown'
Sanity check: array([1], dtype=int32)

== env ==========================================================
LD_LIBRARY_PATH :/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/gruntdata/qihoo360/cuda/lib64
DYLD_LIBRARY_PATH is unset

== nvidia-smi ===================================================
Wed Sep 12 13:34:30 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.26                 Driver Version: 375.26                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K40m          On   | 0000:02:00.0     Off |                    0 |
| N/A   36C    P0    67W / 235W |   1161MiB / 11439MiB |     39%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Tesla K40m          On   | 0000:03:00.0     Off |                    0 |
| N/A   35C    P0    60W / 235W |     73MiB / 11439MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0     13950    C   bin/arks                                       868MiB |
|    0     27880    C   python3.6                                      288MiB |
|    1     27880    C   python3.6                                       71MiB |
+-----------------------------------------------------------------------------+

== cuda libs  ===================================================
/usr/local/cuda-8.0/doc/man/man7/libcudart.7
/usr/local/cuda-8.0/doc/man/man7/libcudart.so.7
/usr/local/cuda-8.0/lib64/libcudart_static.a
/usr/local/cuda-8.0/lib64/libcudart.so.8.0.61
/usr/local/cuda-7.5/doc/man/man7/libcudart.7
/usr/local/cuda-7.5/doc/man/man7/libcudart.so.7
/usr/local/cuda-7.5/lib64/libcudart.so.7.5.18
/usr/local/cuda-7.5/lib64/libcudart_static.a
/usr/local/cuda-7.5/lib/libcudart.so.7.5.18
/usr/local/cuda-7.5/lib/libcudart_static.a

【问题讨论】:

    标签: tensorflow recurrent-neural-network tensor


    【解决方案1】:

    已解决,返回值格式改为元组

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      • 2021-05-17
      • 2016-02-29
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      相关资源
      最近更新 更多