PDF interpolation with Tensorflow
PDFFlow is parton distribution function interpolation library written in Python and based on the TensorFlow framework. It is developed with a focus on speed and efficiency, enabling researchers to perform very expensive calculation as quick and easy as possible.
The key features of PDFFlow is the possibility to query PDF sets on GPU accelerators.
The documentation for PDFFlow can be consulted in the readthedocs page: pdfflow.readthedocs.io.
The package can be installed with pip:
python3 -m pip install pdfflow
If you prefer a manual installation just use:
python setup.py install
or if you are planning to extend or develop code just use:
python setup.py develop
⚠ Note: Use the latest version of TensorFlow!
TensorFlow is updated frequently and a later version of TensorFlow will often
offer better performance in both GPUs and CPUs.
Although it can be made to work with earlier versions,
PDFFlow is only supported for TensorFlow>2.1.
Minimal Working Example
Below a minimalistic example where
PDFFlow is used to generate a 10 values of the PDF
for 2 members for three different flavours.
from pdfflow import mkPDFs import tensorflow as tf pdf = mkPDFs("NNPDF31_nnlo_as_0118", [0,2]) x = tf.random.uniform(, dtype=tf.float64) q2 = tf.random.uniform(, dtype=tf.float64)*20 + 10 pid = tf.cast([-1,21,1], dtype=tf.int32) result = pdf.xfxQ2(pid, x, q2)
Note the usage of the
dtype keyword inm the TensorFlow calls.
This is used to ensure that
float64 is being used all across the program.
For convenience, we ship two functions,
float_me which are simply
tf.cast with the right types.
These wrappers can be used over TensorFlow types but also numpy values:
from pdfflow import mkPDFs, int_me, float_me import tensorflow as tf import numpy as np pdf = mkPDFs("NNPDF31_nnlo_as_0118", [0,2]) x = float_me(np.random.rand(10)) q2 = float_me(tf.random.uniform()*20 + 10) pid = int_me([-1,21,1]) result = pdf.xfxQ2(pid, x, q2)
If you use the package pelase cite the following paper and zenodo references:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pdfflow-1.2.1-py3-none-any.whl (31.9 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size pdfflow-1.2.1.tar.gz (27.1 kB)||File type Source||Python version None||Upload date||Hashes View|