Python Bindings (WIP) - PetaVision/OpenPV GitHub Wiki
Build Instructions
After cloning OpenPV:
cd OpenPV; git checkout pybind; git submodule update
Now create a build folder and run ccmake as usual. Press T to open the advanced configuration and set the following options:
PV_BUILD_SHARED: ON
CUDA_NVCC_FLAGS: -Xcompiler -fPIC
CUDA_USE_STATIC_CUDA_RUNTIME: OFF
Run make and ensure PetaVision builds with no errors. Now go back into ccmake and enable:
PV_BUILD_PYTHON: ON
Run make one more time and there should now be a file with a name like PythonBindings.cpython-x.so. Make a symlink to this file inside OpenPV/python/OpenPV:
cd OpenPV/python/OpenPV; ln path-to-PythonBindings-file .
Now you can use the bindings by adding this to the top of your Python script:
import sys
sys.path.append('path-to-OpenPV/python')
import OpenPV
Using the library
Classes
PetaVision
PetaVision(args_dict, params_string)
begin()
advance(num_steps)
finish()
get_connection_weights(conn_name)
set_connection_weights(conn_name, np_float_array)
get_layer_activity(layer_name)
get_layer_state(layer_name)
set_layer_state(layer_name, np_float_array)
is_finished()
get_probe_values(probe_name)
is_root()
wait_for_commands()
Runner
See cifar_example.py for how to use.