diff --git a/10-ColorBot/utils.py b/10-ColorBot/utils.py index 996e4bd..8812872 100644 --- a/10-ColorBot/utils.py +++ b/10-ColorBot/utils.py @@ -13,8 +13,8 @@ def parse(line): # Each line of the dataset is comma-separated and formatted as # color_name, r, g, b # so `items` is a list [color_name, r, g, b]. - items = tf.string_split([line], ",").values - rgb = tf.strings.to_number(items[1:], out_type=tf.float32) / 255. + items = tf.compat.v1.string_split([line], ",").values + rgb = tf.compat.v1.strings.to_number(items[1:], out_type=tf.float32) / 255. # Represent the color name as a one-hot encoded character sequence. color_name = items[0] chars = tf.one_hot(tf.io.decode_raw(color_name, tf.uint8), depth=256) @@ -60,4 +60,4 @@ def load_dataset(data_dir, url, batch_size): dataset = tf.data.TextLineDataset(path).skip(1).map(parse).shuffle( buffer_size=10000).padded_batch( batch_size, padded_shapes=([None], [None, None], [])) - return dataset \ No newline at end of file + return dataset