GithubHelp home page GithubHelp logo

philjd / tf-quaternion Goto Github PK

View Code? Open in Web Editor NEW
54.0 7.0 17.0 47 KB

An implementation of quaternions for and written in tensorflow. Fully differentiable.

License: Apache License 2.0

Python 100.00%
tensorflow quaternion quaternions python

tf-quaternion's People

Contributors

alexharn avatar felixfrank avatar lxzheng avatar philjd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tf-quaternion's Issues

TypeError: Got an unexpected keyword argument 'keep_dims'

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'

Quaternion.abs squashes dimensions

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?

norm() should have a sqrt

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

ValueError: Can't create a quaternion from a tensor with shape (?,6). The last dimension must be 4.

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 )

ValueError: Cannot infer num from shape(?,?) when using as_rotation_matrix with a dynamic type

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.