Package: fastTF
fastTF is a easy way to convert a Pandas DataFrame into a Tensorflow TFRecord. Also with fastTF you will be able to get the example_spec.Why would you do so?With a TFRecord file you will be able to make your input pipeline fasterBinary data takes up less space on disk, takes less time to copy and can be read much more efficiently from disk.TechfastTF uses a number of open source projects to work properly:Tensorflow- "An end-to-end open source machine learning platform"Pandas- "pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool,
built on top of the Python programming language."InstallationtfFast requiresPython3.6 to run.Install the necessary packages and dependencies$pip3installtensorflow
$pip3installpandasDevelopmentWant to contribute? Great!fastTF uses Tensorflow + Pandas for fast development.Fork these repository and change app.py.Open your Terminal and run these commands to edit the files$cdfastTF
$nanoapp.pyExampledef test_function():
    """
        Test the package
        :return: if the program was successful.
        >>> test_function()
        True

    """
    data = pd.read_csv('diabetes.csv')
    test = tfRecordWriter(data)
    test.write('new.tfrecords')

    with open('example_spec.pickle','rb') as f:
        example_spec = pickle.load(f)
    assert example_spec == test.get_example_spec()

    data = tf.data.TFRecordDataset('new.tfrecords')
    func = lambda x: tf.io.parse_single_example(x,example_spec)
    data = data.map(func)
    y = data.take(1)
    for x in y:
      assert x['Age'].numpy() == 50
    return TrueMetricsMemory TestMemoryTest

Line#    Mem usage    Increment   Line Contents================================================1importpandasaspd2fromfastTFimporttfRecordWriter3importtensorflowastf4importpickle5importdoctest6importpytest78300.7MiB300.7MiB9301.0MiB0.2MiBdeftest_function():10301.0MiB0.0MiB"""11    301.0 MiB      0.0 MiB           Test the package12                                     >>> test_function()13    301.0 MiB      0.0 MiB           True14    301.0 MiB      0.0 MiB15    301.0 MiB      0.0 MiB       """16data=pd.read_csv('diabetes.csv')17301.0MiB0.0MiBtest=tfRecordWriter(data)18301.0MiB0.0MiBtest.write('new.tfrecords')19301.0MiB0.0MiB20301.0MiB0.0MiBwithopen('example_spec.pickle','rb')asf:21301.3MiB0.2MiBexample_spec=pickle.load(f)22301.3MiB0.0MiBassertexample_spec==test.get_example_spec()2324data=tf.data.TFRecordDataset('new.tfrecords')25func=lambdax:tf.io.parse_single_example(x,example_spec)26data=data.map(func)27y=data.take(1)28forxiny:29assertx['Age'].numpy()==5030returnTrueSpeed TestTimerunit:1e-06s

Totaltime:0.644076s
File:/notebooks/package/tests/test_sample.py
Function:test_functionatline8Line#      Hits         Time  Per Hit   % Time  Line Contents==============================================================8deftest_function():916395.06395.01.0data=pd.read_csv('diabetes.csv')101602.0602.00.1test=tfRecordWriter(data)111589870.0589870.091.6test.write('new.tfrecords')1213157.057.00.0withopen('example_spec.pickle','rb')asf:14179.079.00.0example_spec=pickle.load(f)15128.028.00.0assertexample_spec==test.get_example_spec()161718591.08591.01.3data=tf.data.TFRecordDataset('new.tfrecords')1813.03.00.0func=lambdax:tf.io.parse_single_example(x,example_spec)19125952.025952.04.0data=data.map(func)201245.0245.00.0y=data.take(1)21212227.06113.51.9forxiny:22127.027.00.0assertx['Age'].numpy()==50Another Example>>>importpandasaspd
>>>data=pd.read_csv('diabetes.csv')>>>fromfastTFimporttfRecordWriter
>>>demo=tfRecordWriter(data)>>>demo.write("name.tfrecord")>>>test.get_example_spec(){'Pregnancies':FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'Glucose',FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'BloodPressure':FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'SkinThickness':FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'Insulin':FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'Age':FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'Outcome':FixedLenFeature(shape=(),dtype=tf.int64,default_value=None),'BMI':FixedLenFeature(shape=(),dtype=tf.float32,default_value=None),'DiabetesPedigreeFunction':FixedLenFeature(shape=(),dtype=tf.float32,default_value=None)}TodosWrite more TestsMake the app faster