hammerlab / flowdec

TensorFlow Deconvolution for Microscopy Data
Apache License 2.0
86 stars 26 forks source link

Python updates for recent changes in tensorflow and dependent libs #28

Closed chrisroat closed 4 years ago

chrisroat commented 4 years ago

Almost all changes are renames. Some of the renames for TF use V1 compatibility API, which means eager evaluation will not work (I believe).

This will break those using older TF, scipy, skimage versions.

Tested in TF 1.14, 1.15, and 2.0, with and without GPU: python/flowdec/*_test.py all pass python/tests/smoketests.sh runs

chrisroat commented 4 years ago

FYI. The change to numpy_function was the result of the following warning. Of the two solutions, the switch I made should be equivalent. I believe it just won't allow extra functionality around eager evaluation.

..WARNING:tensorflow:From /Users/chrisroat/flowdec/python/flowdec/tf_ops.py:31: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version.
Instructions for updating:
tf.py_func is deprecated in TF V2. Instead, there are two
    options available in V2.
    - tf.py_function takes a python function which manipulates tf eager
    tensors instead of numpy arrays. It's easy to convert a tf eager tensor to
    an ndarray (just call tensor.numpy()) but having access to eager tensors
    means `tf.py_function`s can use accelerators such as GPUs as well as
    being differentiable using a gradient tape.
    - tf.numpy_function maintains the semantics of the deprecated tf.py_func
    (it is not differentiable, and manipulates numpy arrays). It drops the
    stateful argument making all functions stateful.
eric-czech commented 4 years ago

Awesome @chrisroat! Thanks for pushing this back.

eric-czech commented 4 years ago

FYI I cut a new PyPi release with your changes and relevant version bounds at https://pypi.org/project/flowdec/1.1.0/

chrisroat commented 4 years ago

Fixes: #27

Appreciate the new release. Thanks!