Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 利用Conv1D进行张量流整形_Python 3.x_Tensorflow - Fatal编程技术网

Python 3.x 利用Conv1D进行张量流整形

Python 3.x 利用Conv1D进行张量流整形,python-3.x,tensorflow,Python 3.x,Tensorflow,我在这里看到了与堆栈溢出类似的问题,但不完全相同。我可以在使用完全连接的NN层时重塑形状,但不能使用Conv1D层。这里有一个最小的例子。我在Python3.6.3上使用TF1.4.0 import tensorflow as tf # fully connected fc = tf.placeholder(tf.float32, [None,12]) fc = tf.contrib.layers.fully_connected(fc, 12) fc = tf.contrib.layers.f

我在这里看到了与堆栈溢出类似的问题,但不完全相同。我可以在使用完全连接的NN层时重塑形状,但不能使用Conv1D层。这里有一个最小的例子。我在Python3.6.3上使用TF1.4.0

import tensorflow as tf

# fully connected
fc = tf.placeholder(tf.float32, [None,12])
fc = tf.contrib.layers.fully_connected(fc, 12)
fc = tf.contrib.layers.fully_connected(fc, 6)
fc = tf.reshape(fc, [-1,3,2])

# convolutional
con = tf.placeholder(tf.float32, [None,50,4])
con = tf.layers.Conv1D(con, 12, 3, activation=tf.nn.relu)
con = tf.layers.Conv1D(con, 6, 3, activation=tf.nn.relu)
con = tf.reshape(con, [-1,50,3,2])
这是输出是的,我知道RuntimeWarning。我发现的讨论它的信息表明它是无害的,但是如果你知道其他的,请分享!:

/usr/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/tensor_util.py", line 468, in make_tensor_proto
    str_values = [compat.as_bytes(x) for x in proto_values]
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/tensor_util.py", line 468, in <listcomp>
    str_values = [compat.as_bytes(x) for x in proto_values]
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
    (bytes_or_text,))
TypeError: Expected binary or unicode string, got <tensorflow.python.layers.convolutional.Conv1D object at 0x7fa67e0d1a20>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "minimal reshape example.py", line 16, in <module>
    con = tf.reshape(con, [-1,width,3,2])
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape
    "Reshape", tensor=tensor, shape=shape, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper
    raise err
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
    preferred_dtype=default_dtype)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 926, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 229, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/constant_op.py", line 208, in constant
    value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/tensor_util.py", line 472, in make_tensor_proto
    "supported type." % (type(values), values))
TypeError: Failed to convert object of type <class 'tensorflow.python.layers.convolutional.Conv1D'> to Tensor. Contents: <tensorflow.python.layers.convolutional.Conv1D object at 0x7fa67e0d1a20>. Consider casting elements to a supported type.
我的代码在con=tf.reformecon、[-1,50,3,2]时失败。然而,该模式与我用于完全连通图fc的模式几乎相同

我在TensorFlow的高级API中创建了与这些工作非常相似的网络,称为。然而一个多月后,我还没有在GitHub上与TFLearn的开发人员进行交流

我不介意使用TensorFlow的本机估计器,但我必须解决这个重塑问题才能实现它。

我发现了错误:tf.layers.Conv1D!=tf.layers.conv1d。将前者改为后者消除了错误。让TensorFlow/Python用户当心

尽管TensorFlow似乎避免了Python的对象模型(这可能是必要的),但考虑到分布式、低级计算的可能性,实际上Python API中有一些真正的类。类构造函数可以接受多个all?与命名类似的便利函数具有相同的参数