def testMakeOutputDictError(self):
schema = self.toSchema({'a': tf.VarLenFeature(tf.string)})
# SparseTensor that cannot be represented as VarLenFeature.
fetches = {
'a': tf.SparseTensorValue(indices=np.array([(0, 2), (0, 4), (0, 8)]),
values=np.array([10.0, 20.0, 30.0]),
dense_shape=(1, 20))
}
with self.assertRaisesRegexp(
ValueError, 'cannot be decoded by ListColumnRepresentation'):
_ = impl_helper.make_output_dict(schema, fetches)
# SparseTensor of invalid rank.
fetches = {
'a': tf.SparseTensorValue(
indices=np.array([(0, 0, 1), (0, 0, 2), (0, 0, 3)]),
values=np.array([10.0, 20.0, 30.0]),
dense_shape=(1, 10, 10))
}
with self.assertRaisesRegexp(
ValueError, 'cannot be decoded by ListColumnRepresentation'):
_ = impl_helper.make_output_dict(schema, fetches)
# SparseTensor with indices that are out of order.
fetches = {
'a': tf.SparseTensorValue(indices=np.array([(0, 2), (2, 4), (1, 8)]),
values=np.array([10.0, 20.0, 30.0]),
dense_shape=(3, 20))
}
with self.assertRaisesRegexp(
ValueError, 'Encountered out-of-order sparse index'):
_ = impl_helper.make_output_dict(schema, fetches)
评论列表
文章目录