我是使用python 3的tensorflow 2的初学者。我正在学习youtube上的课程。当我在google collab中键入代码时,得到的结果是(30,4)其中,当我在Pycharm或Visual Studio等IDE中键入相同的代码时,得到的结果是预期的,即(120,4)正确的结果应该是(120,4)。有人可以帮忙吗?
The result I got when typed the code on Google collab The result I got when typed the code on Pycharm
我在Google合作实验室中使用的代码如下;
''' %tensorflow_version 2.x#仅在Google collab中需要此行 从未来导入absolute_import,division,print_function,unicode_literals 将tensorflow作为tf导入 将熊猫作为pd导入
CSV_COLUMN_NAMES = ['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth', 'Species']
SPECIES = ['Setosa', 'Versicolor', 'Virginica']
train_path = tf.keras.utils.get_file("iris_training.csv",
"https://storage.googleapis.com/download.tensorflow.org/data/iris_test.csv")
test_path = tf.keras.utils.get_file("iris_test.csv",
"https://storage.googleapis.com/download.tensorflow.org/data/iris_test.csv")
train = pd.read_csv(train_path, names=CSV_COLUMN_NAMES, header=0)
test = pd.read_csv(test_path, names=CSV_COLUMN_NAMES, header=0)
train.head()
train_y = train.pop('Species')
test_y = test.pop('Species')
train.head()
train_y.head()
train.shape
print(train.shape)
'''