Tôi đang cố gắng áp dụng phần chuyên gia của hướng dẫn cho dữ liệu của riêng tôi nhưng tôi tiếp tục gặp phải các lỗi kích thước. Đây là mã dẫn đến lỗi.Làm cách nào để sửa lỗi thứ nguyên trong TensorFlow?
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def bias_variable(shape):
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial)
def conv2d(x, W):
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
def max_pool_2x2(x):
return tf.nn.max_pool(x, ksize=[1, 2, 2, 1],
strides=[1, 2, 2, 1], padding='SAME')
W_conv1 = weight_variable([1, 8, 1, 4])
b_conv1 = bias_variable([4])
x_image = tf.reshape(tf_in, [-1,2,8,1])
h_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)
Và sau đó khi tôi cố gắng chạy lệnh này:
W_conv2 = weight_variable([1, 4, 4, 8])
b_conv2 = bias_variable([8])
h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
h_pool2 = max_pool_2x2(h_conv2)
tôi nhận được các lỗi sau đây:
ValueError Traceback (most recent call last)
<ipython-input-41-7ab0d7765f8c> in <module>()
3
4 h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)
----> 5 h_pool2 = max_pool_2x2(h_conv2)
ValueError: ('filter must not be larger than the input: ', 'Filter: [', Dimension(2), 'x', Dimension(2), '] ', 'Input: [', Dimension(1), 'x', Dimension(4), '] ')
Chỉ cần đối với một số thông tin cơ bản, các dữ liệu mà tôi đang đối phó với một tệp CSV trong đó mỗi hàng chứa 10 tính năng và 1 cột trống có thể là 1 hoặc 0. Tôi đang cố gắng lấy được xác suất trong cột trống mà cột sẽ bằng 1.
'tf_in' là gì? Tôi giả sử nó là đầu vào 1x8 gốc. – erickrf
'data = genfromtxt ('cs-training.csv', delimiter = ',')'. 'A = data.shape [1] -1'. 'tf_in = tf.placeholder (" float ", [None, A])'. – NickTheInventor