Python ValueError:无法为张量';输入形状(10,)的值;TargetsData/Y:0';,其形状为';(?,1)和#x27;

Python ValueError:无法为张量';输入形状(10,)的值;TargetsData/Y:0';,其形状为';(?,1)和#x27;,python,tensorflow,Python,Tensorflow,我一直遇到这个错误。我认为形状应该是:无,2,因为程序中有2个功能。csv文件有4个功能。其中一个被过滤掉了。一个被读取为目标。我应该怎么做才能消除这个错误 ValueError:无法为张量“TargetsData/Y:0”输入形状(10,)的值,该张量具有形状“(?,1)”如果我将标签从1-D更改为2-D,我看不到该错误 import os import json import datetime import numpy as np import pandas as pd import ma

我一直遇到这个错误。我认为形状应该是:无,2,因为程序中有2个功能。csv文件有4个功能。其中一个被过滤掉了。一个被读取为目标。我应该怎么做才能消除这个错误


ValueError:无法为张量“TargetsData/Y:0”输入形状(10,)的值,该张量具有形状“(?,1)”

如果我将标签从1-D更改为2-D,我看不到该错误

import os
import json
import datetime
import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.formula.api as sm

import tflearn
import tensorflow as tf 

data = pd.read_csv("line.csv")

data.columns = ['total', 'saved', 'lines' , 'inv']
target = list(data['saved'])


#function filter out the columns we wont be using to train the machine 
def preprocess(data, columns_to_ignore):
    data = data.drop(columns=columns_to_ignore)
    return data 

ignore = ['saved' , 'inv']

data = preprocess(data, ignore)

train = [list(l) for l in zip(data['total'], data['lines'])]

# Build neural network
net = tflearn.input_data(shape=[None, 2])
net = tflearn.fully_connected(net, 16)
net = tflearn.fully_connected(net, 16)
net = tflearn.fully_connected(net, 1, activation='softmax')
net = tflearn.regression(net)

# Training Neural Network
model = tflearn.DNN(net)

# Start Training using tensorflow gradient descent algorithim 
model = model.fit(train, target, n_epoch=10, batch_size=10, show_metric=True)
target = list(data['y'])
a = np.array(target)
target = np.reshape(a , (-1,1))