Skip to content

Commit 7cd8bfe

Browse files
committed
TF1.6 compatibility
1 parent edacbb4 commit 7cd8bfe

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

examples/mnist/mnist_data_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def readMNIST(sc, output, format):
110110
tfRDD = sc.newAPIHadoopFile(output, "org.tensorflow.hadoop.io.TFRecordFileInputFormat",
111111
keyClass="org.apache.hadoop.io.BytesWritable",
112112
valueClass="org.apache.hadoop.io.NullWritable")
113-
imageRDD = tfRDD.map(lambda x: fromTFExample(str(x[0])))
113+
imageRDD = tfRDD.map(lambda x: fromTFExample(bytes(x[0])))
114114

115115
num_images = imageRDD.count()
116116
num_labels = labelRDD.count() if labelRDD is not None else num_images

examples/mnist/spark/mnist_spark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def toNumpy(bytestr):
5454
label = numpy.array(features['label'].int64_list.value)
5555
return (image, label)
5656

57-
dataRDD = images.map(lambda x: toNumpy(str(x[0])))
57+
dataRDD = images.map(lambda x: toNumpy(bytes(x[0])))
5858
else:
5959
if args.format == "csv":
6060
images = sc.textFile(args.images).map(lambda ln: [int(x) for x in ln.split(',')])

examples/mnist/spark/mnist_spark_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def toNumpy(bytestr):
5454
label = numpy.array(features['label'].int64_list.value)
5555
return (image, label)
5656

57-
dataRDD = images.map(lambda x: toNumpy(str(x[0])))
57+
dataRDD = images.map(lambda x: toNumpy(bytes(x[0])))
5858
else: # args.format == "csv":
5959
images = sc.textFile(args.images).map(lambda ln: [int(x) for x in ln.split(',')])
6060
labels = sc.textFile(args.labels).map(lambda ln: [float(x) for x in ln.split(',')])

0 commit comments

Comments
 (0)