Created
June 19, 2019 17:19
-
-
Save ivelin/2ec21d2b5298bf88ae3b36947d338cff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""PcapDataset""" | |
import tensorflow as tf | |
from tensorflow_io.core.python.ops import data_ops as data_ops | |
from tensorflow_io import _load_library | |
pcap_ops = _load_library('_pcap_ops.so') | |
class PcapDataset(data_ops.Dataset): | |
"""A pcap Dataset. Pcap is a popular file format for capturing network packets. | |
""" | |
def __init__(self, filenames, batch=None): | |
"""Create a pcap Reader. | |
Args: | |
filenames: A `tf.string` tensor containing one or more filenames. | |
""" | |
batch = 0 if batch is None else batch | |
dtypes = [tf.float64, tf.string] | |
shapes = [ | |
tf.TensorShape([]), tf.TensorShape([])] if batch == 0 else [ | |
tf.TensorShape([None]), tf.TensorShape([None])] | |
super(PcapDataset, self).__init__( | |
pcap_ops.pcap_dataset, | |
pcap_ops.pcap_input(filenames), | |
batch, dtypes, shapes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment