Closed rcremese closed 1 year ago
Hi again,
pdoc
doesn't automatically link to the PhiTreeNode documentation. I'll look into it. If you know why the links are broken, let me know.I found the reason for the broken links. The online documentation will be fixed once 2.3 is released (which should be within the week).
Thank you for the quick response. I also saw several broken links for demos in the documentation. If you are interested, I can list some of them. I will try to provide you a reproducible error as soon as possible. What is the best for this ? A collab notebook or a python file with all the dependencies listed ?
Sure, if you have a list, that would be great! A Python file would be the easiest to debug for me.
from phi.jax import flow
import matplotlib.pyplot as plt
import numpy as np
# Field and gradient field definition
def l2(x):
return flow.math.l2_loss(x)
field = flow.CenteredGrid(l2, bounds=flow.Box(x=(-1,1), y=(-1,1)),x=100, y=100)
gradient_field = flow.field.spatial_gradient(-field, type=flow.StaggeredGrid)
# Point cloud definition
points=[]
for x in np.linspace(-0.9,0.9,10):
for y in np.linspace(-0.9,0.9,10):
points.append(flow.vec(x=x, y=y))
points = flow.tensor(points, flow.instance('point'))
point_cloud = flow.PointCloud(points, bounds=field.bounds)
# First visualisation
flow.vis.plot([field, gradient_field, point_cloud], show_color_bar=False, same_scale=False)
# Advection functions definition (with and without decorator)
jited_advection = flow.math.jit_compile(flow.advect.points)
@flow.math.jit_compile
def step(point_cloud :flow.PointCloud, field: flow.field.Field, dt : float):
return flow.advect.points(point_cloud, gradient_field, dt=0.1)
history = []
for t in range(10):
## 1 Works fine if not jit compiled
point_cloud = flow.advect.points(point_cloud, gradient_field, dt=0.1)
## 2 test cases in which jit compilation through an error
# point_cloud = jited_advection(point_cloud, gradient_field, dt=0.1)
# point_cloud = step(point_cloud, gradient_field, dt=0.1)
history.append(point_cloud)
# Final visualisation
flow.stack(history, flow.batch('time'))
flow.vis.plot(history, animate='time')
plt.show()
Sorry to put it in comment of this issue but I haven't found an email adress to send you my python file. For the bug to occur, simply comment l.33 and uncomment l.35 or l.36. The thrown error is the one I copied in the first message.
My PhiFlow version : phiflow @ git+https://github.com/tum-pbs/PhiFlow@128d0809675b0be370c37d260ad19dae64a7d22e My backend : JAX
Some of the boken links found in the documentation :
I don't know how hard it would be to implement, but having a search tool for the documentation would be a nice feature.
I'll check it out, soon.
The error seems to be fixed on the latest 2.3-develop
version.
You can upgrade by first uninstalling phiflow, then
pip install git+https://github.com/tum-pbs/PhiFlow@2.3-develop
I've updated the links there as well.
Sorry to bother you again but it seems the 2.3-develop tag is unknown.
pip install git+https://github.com/tum-pbs/PhiFlow@2.3-develop
Collecting git+https://github.com/tum-pbs/PhiFlow@2.3-develop
Cloning https://github.com/tum-pbs/PhiFlow (to revision 2.3-develop) to /tmp/pip-req-build-5o0sgquo
Running command git clone --filter=blob:none --quiet https://github.com/tum-pbs/PhiFlow /tmp/pip-req-build-5o0sgquo
WARNING: Did not find branch or tag '2.3-develop', assuming revision or ref.
Running command git checkout -q 2.3-develop
error: pathspec '2.3-develop' did not match any file(s) known to git.
error: subprocess-exited-with-error
Yeah, 2.3 has been released! You can now write
$ pip install phiflow==2.3.0
The fixed documentation is also online!
Hi, it's me again, I'm still using phiflow and enjoyed it so far but I'm stuck with a documentation issue. In the jit_compile documentation page it's written the following : Args f Function to be traced. All positional arguments must be of type Tensor or PhiTreeNode returning a single Tensor or PhiTreeNode.
But I can not find any information about the PhiTreeNode class in the documentation. Would be nice to include a link to the class or to remove it from the doc if deprecated. Morever, I managed to implement a jit-compiled method which arguments weren't Tensors but CenteredGrid and int, are this special case of PhiTreeNode ?
Additionally, I'm facing a problem when trying to jit-compile the advection fonction with your wrapper. The input to the advection function is a PointCloud of Tensors I want to advect with velocity field, represented as a centered grid, and which is the second parameter of the function. Given that
jited_advection = flow.math.jit_compile(flow.advect.advect)
and that I try to jit-compile the advection function to improve its speed, I get the following error message which is particularly unhelpfull :Used backend : JAX
I would love to know if it's possible to jit compile the advection function and to differentiate through it. Thank you for the time you might take to respond.