philjd / tf-quaternion Goto Github PK
View Code? Open in Web Editor NEWAn implementation of quaternions for and written in tensorflow. Fully differentiable.
License: Apache License 2.0
An implementation of quaternions for and written in tensorflow. Fully differentiable.
License: Apache License 2.0
Hi PhilJD,
May I know what Tensorflow version does this library supports? Thanks
When using a tensor of shape [N, 4]
, the Quaternion.abs
function produces a scalar. I would expect this to behave more like the Quaternion.norm
function, which does preserve dimensions. An unfortunate side effect of this is that the Quaternion.normalized
scales each quaternion by the same scalar, instead of by the norm of each quaternion. Is my understanding of the expected functionality correct?
EDIT: Given the definition of normalized quaternion, shouldn't norm() return self._q / self.abs(), because I was expecting the normalized quaternion when I called norm() and I am sure other people might make that mistake, given that you have a different method "abs()" for the actual norm of a quaternion
I am getting the following Error AttributeError: 'numpy.ndarray' object has no attribute 'normalized'. could somone help? thank you in advance
Hi,
I am trying to normalize the quaternion, but I encountered this error.
q = tfq.Quaternion([0.1, 0.5, 0.1, 0.001]).normalized()
TypeError Traceback (most recent call last)
in
----> 1 q = tfq.Quaternion([0.1, 0.5, 0.1, 0.001]).normalized()
2 q
/disk/anaconda3/lib/python3.7/site-packages/tfquaternion/tfquaternion.py in scoped_func(*args, **kwargs)
/disk/anaconda3/lib/python3.7/site-packages/tfquaternion/tfquaternion.py in normalized(self)
/disk/anaconda3/lib/python3.7/site-packages/tfquaternion/tfquaternion.py in scoped_func(*args, **kwargs)
/disk/anaconda3/lib/python3.7/site-packages/tfquaternion/tfquaternion.py in abs(self, keepdims)
/disk/anaconda3/lib/python3.7/site-packages/tfquaternion/tfquaternion.py in scoped_func(*args, **kwargs)
/disk/anaconda3/lib/python3.7/site-packages/tfquaternion/tfquaternion.py in norm(self, keepdims)
/disk/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/traceback_utils.py in error_handler(*args, **kwargs)
151 except Exception as e:
152 filtered_tb = _process_traceback_frames(e.traceback)
--> 153 raise e.with_traceback(filtered_tb) from None
154 finally:
155 del filtered_tb
/disk/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in op_dispatch_handler(*args, **kwargs)
1074 if iterable_params is not None:
1075 args, kwargs = replace_iterable_params(args, kwargs, iterable_params)
-> 1076 result = api_dispatcher.Dispatch(args, kwargs)
1077 if result is not NotImplemented:
1078 return result
TypeError: Got an unexpected keyword argument 'keep_dims'
i try to rotate vectors with an array or quaterion, seems not working for me
Thanks for the module but it is not compatible with TF1.13 (stable) or TF2.0 (alpha) due to the keyword argument keep_dims
being deprecated. Please use keepdims
in functions like reduce_sum()
.
I am trying to write a metrics using quaternions, the code looks like the follwoing:
def vectorMAEquat(y_true,y_pred):
p1 = tf.constant([[1,0,0],[0,1,0],[0,0,1]],dtype=tf.float32)
p2 = tf.constant([[1,0,0],[0,1,0],[0,0,1]],dtype=tf.float32)
q1 = tfq.Quaternion(y_true)
q2 = tfq.Quaternion(y_pred)
rot1 = tf.matmul(q1.as_rotation_matrix(),p1)
rot2 = tf.matmul(q2.as_rotation_matrix(),p2)
return K.mean(K.abs(rot1 - rot2))
However, this gives me the error: ValueError: Cannot infer num from shape(?,?)
which comes form the function
w,x,y,z = tf.unstack(self.normalized().value(),axis=-1)
from the file tfquaternion.py
, in line 364
in the function as_rotation_matrix
.
A little bit of googling brought me here: https://stackoverflow.com/questions/45404056/tf-unstack-with-dynamic-shape
So, maybe this would be a nice feature, if as_rotation_matrix could work with dynamic_partition, but I am not fluent enough in tensorflow to achieve this, so any pointers would be really appreciated.
Thank you
Hello and thank you for this awesome repo.
I am quite certain that this is not a direct issue with this repo, but more or less a tensorflow issue which arises here. But I hope that somebody might help me with it...
If one does the following:
q1 = tfq.Quaternion(y[:-3])
and y
is a 6 element vector then the error will come:
ValueError: Can't create a quaternion form a tensor with shape (?,6). The last dimension must be 4.
So I am wondering what would be the best way to slice an array to 4 element vector which can then be passed to the lib?
I tried it with creatin a variable, however this results in a whole other complication, since the shape must be known beforehand,... (see here: https://stackoverflow.com/questions/51493490/validate-shape-equivalent-in-keras-in-comparison-to-tensorflow )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.