Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 68398ab

Browse files
committed
Use pandas for examples, removed csv import
1 parent b82c94a commit 68398ab

9 files changed

+8
-20
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
# If you have contributed a few PRs, feel free to send a PR adding yourself here.
1010

1111
Google Inc.
12-
Yuan (Terry) Tang [email protected]
12+

CONTRIBUTORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# If you have contributed a few PRs, feel free to send a PR adding yourself here.
1313

1414
Illia Polosukhin [email protected]
15-
Yuan (Terry) Tang [email protected]
15+

examples/text_classification.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import csv
1615
import numpy as np
1716
from sklearn import metrics
1817
import pandas

examples/text_classification_character_cnn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
https://github.com/zhangxiangxiao/Crepe
2525
"""
2626

27-
import csv
2827
import numpy as np
2928
from sklearn import metrics
3029
import pandas

examples/text_classification_character_rnn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
https://github.com/zhangxiangxiao/Crepe
2525
"""
2626

27-
import csv
2827
import numpy as np
2928
from sklearn import metrics
3029
import pandas

examples/text_classification_cnn.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import csv
1615
import numpy as np
1716
from sklearn import metrics
1817
import pandas

examples/text_classification_save_restore.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# limitations under the License.
1414

1515
import os
16-
import csv
1716
import numpy as np
1817
from sklearn import metrics
18+
import pandas
1919

2020
import tensorflow as tf
2121
from tensorflow.models.rnn import rnn, rnn_cell
@@ -27,17 +27,10 @@
2727
# https://drive.google.com/folderview?id=0Bz8a_Dbh9Qhbfll6bVpmNUtUcFdjYmF2SEpmZUZUcVNiMUw1TWN6RDV3a0JHT3kxLVhVR2M
2828
# Unpack: tar -xvf dbpedia_csv.tar.gz
2929

30-
def load_dataset(filename):
31-
target = []
32-
data = []
33-
reader = csv.reader(open(filename), delimiter=',')
34-
for line in reader:
35-
target.append(int(line[0]))
36-
data.append(line[2])
37-
return data, np.array(target, np.float32)
38-
39-
X_train, y_train = load_dataset('dbpedia_csv/train.csv')
40-
X_test, y_test = load_dataset('dbpedia_csv/test.csv')
30+
train = pandas.read_csv('dbpedia_csv/train.csv', header=None)
31+
X_train, y_train = train[2], train[0]
32+
test = pandas.read_csv('dbpedia_csv/test.csv', header=None)
33+
X_test, y_test = test[2], test[0]
4134

4235
### Process vocabulary
4336

skflow/ops/array_ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,3 @@ def one_hot_matrix(tensor_in, num_classes, on_value=1.0, off_value=0.0):
7171
ret = tf.reshape(one_hot_vector, tf.concat(0, [dims, [num_classes]]))
7272
ret.set_shape(tensor_in.get_shape().concatenate(num_classes))
7373
return ret
74-

skflow/ops/conv_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def conv2d(tensor_in, n_filters, filter_shape, strides=None, padding='SAME',
3838
use.
3939
bias: Boolean, if to add bias.
4040
Returns:
41-
A Tensor with resuling convolution.
41+
A Tensor with resulting convolution.
4242
"""
4343
with tf.variable_scope('convolution'):
4444
if strides is None:

0 commit comments

Comments
 (0)