【发布时间】:2018-10-11 13:51:59
【问题描述】:
我一直在看网上的tensorflow教程(特别是房价教程:https://colab.research.google.com/github/tensorflow/models/blob/master/samples/core/tutorials/keras/basic_regression.ipynb)
我一直在尝试使用 google colab 为类似项目上传自己的 csv 文件。但我似乎无法获得正确的格式 - 我对此很陌生,所以我找不到我能理解的解决方案。
from __future__ import absolute_import, division, print_function
import tensorflow as tf
from tensorflow import keras
import numpy as np
import pandas as pd
print(tf.__version__)
#Import the csv files
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name = fn, length = len(uploaded[fn])))
# This is where I upload my csv file
import io
df = pd.read_csv(io.StringIO(uploaded[ 'data.csv'].decode('utf-8')))
df.head()
(train_data, train_labels), (test_data, test_labels) = uploaded.load_data()
# Shuffle the training set
order = np.argsort(np.random.random(train_labels.shape))
train_data = train_data[order]
train_labels = train_labels[order]
print(boston_housing)
这就是问题所在 - 我似乎无法将我的数据分成训练和测试数据。
我的 data.csv 只有 5 列。 Col 1-2 包含两组输入,col3 包含标签,col 3-4 包含测试输入数据。
再次,大量新手,任何帮助都会很棒!我很困惑
【问题讨论】:
标签: tensorflow keras google-colaboratory