小编voi*_*ice的帖子

如何使用tf.reshape()?

import tensorflow as tf

import random

import numpy as np


x= tf.placeholder('float')

x=tf.reshape(x,[-1,28,28,1])

with tf.Session() as sess:

    x1 = np.asarray([random.uniform(0,1) for i in range(784)])

    result = sess.run(x, feed_dict={x: x1})

    print(result)
Run Code Online (Sandbox Code Playgroud)

我在重整形时使用mnist数据时遇到了一些问题,但是这个问题是我的问题的简化版本...为什么此代码实际上不起作用?

表明

“ ValueError:无法为具有形状'(?,28,28,1)'的张量'Reshape:0'输入形状(784,)的值。“

我该怎么解决?

python numpy reshape mnist tensorflow

5
推荐指数
1
解决办法
6969
查看次数

标签 统计

mnist ×1

numpy ×1

python ×1

reshape ×1

tensorflow ×1