本文整理汇总了Python中tensorflow.python.ops.parsing_ops.decode_csv函数的典型用法代码示例。如果您正苦于以下问题:Python decode_csv函数的具体用法?Python decode_csv怎么用?Python decode_csv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode_csv函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test
def _test(self, args, expected_out=None, expected_err_re=None):
if expected_err_re is None:
decode = parsing_ops.decode_csv(**args)
out = self.evaluate(decode)
for i, field in enumerate(out):
if field.dtype == np.float32 or field.dtype == np.float64:
self.assertAllClose(field, expected_out[i])
else:
self.assertAllEqual(field, expected_out[i])
else:
with self.assertRaisesOpError(expected_err_re):
decode = parsing_ops.decode_csv(**args)
self.evaluate(decode)
示例2: _apply_transform
def _apply_transform(self, input_tensors):
default_consts = [constant_op.constant(d, shape=[1])
for d in self._default_values]
parsed_values = parsing_ops.decode_csv(input_tensors[0],
record_defaults=default_consts)
# pylint: disable=not-callable
return self.return_type(*parsed_values)
示例3: _make_test_datasets
def _make_test_datasets(self, inputs, **kwargs):
# Test by comparing its output to what we could get with map->decode_csv
filenames = self._setup_files(inputs)
dataset_expected = core_readers.TextLineDataset(filenames)
dataset_expected = dataset_expected.map(
lambda l: parsing_ops.decode_csv(l, **kwargs))
dataset_actual = readers.CsvDataset(filenames, **kwargs)
return (dataset_actual, dataset_expected)
示例4: benchmarkMapWithStrings
def benchmarkMapWithStrings(self):
self._setUp(self.STR_VAL)
for i in range(len(self._filenames)):
num_cols = self._num_cols[i]
kwargs = {'record_defaults': [['']] * num_cols}
dataset = core_readers.TextLineDataset(self._filenames[i]).repeat()
dataset = dataset.map(lambda l: parsing_ops.decode_csv(l, **kwargs)) # pylint: disable=cell-var-from-loop
self._runBenchmark(dataset, num_cols, 'csv_strings_map_decode_csv')
self._tearDown()
示例5: decode_csv_fn
def decode_csv_fn(x):
return parsing_ops.decode_csv(
x,
record_defaults=[
constant_op.constant([], dtypes.float32),
constant_op.constant([], dtypes.int32),
constant_op.constant([], dtypes.string)
],
field_delim=":")