Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grassmannian test visuaiization for 2D #1803

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Conversation

christine051601
Copy link
Collaborator

@christine051601 christine051601 commented Jan 28, 2023

test for 2d visualization

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jan 28, 2023

Codecov Report

Merging #1803 (d7596ce) into master (6f37453) will decrease coverage by 0.85%.
The diff coverage is 38.67%.

@@            Coverage Diff             @@
##           master    #1803      +/-   ##
==========================================
- Coverage   91.50%   90.64%   -0.85%     
==========================================
  Files         136      137       +1     
  Lines       13738    13963     +225     
==========================================
+ Hits        12569    12655      +86     
- Misses       1169     1308     +139     
Flag Coverage Δ
autograd 86.59% <38.67%> (-0.82%) ⬇️
numpy 86.22% <38.67%> (-0.87%) ⬇️
pytorch 79.79% <38.67%> (-0.72%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
geomstats/visualization/grassmannian.py 38.67% <38.67%> (ø)
geomstats/geometry/positive_reals.py 93.48% <0.00%> (-2.17%) ⬇️
geomstats/geometry/stratified/wald_space.py 88.94% <0.00%> (-1.27%) ⬇️
geomstats/_backend/pytorch/__init__.py 96.63% <0.00%> (-0.24%) ⬇️
geomstats/learning/expectation_maximization.py 82.69% <0.00%> (+2.24%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@christine051601 christine051601 changed the title added grassmannian grassmannian test visuaiization for 2D Jan 30, 2023
Copy link
Collaborator

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address my code review comments, specifically the ones on respecting the hw's guidelines, and resubmit.

Takes Grassmannian generated projection matrix
and converts it to a plotable 2D point.

INPUT: Array of 2x2 projection matricies
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use numpy's convention for docstrings, see guidelines:
https://github.com/bioshape-lab/ece594n/tree/main/hw_geomviz

Takes Grassmannian generated projection matrix and
converts it to a plotable 3D point.

INPUT: Array of 3x3 projection matricies or a single projection matrix
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def two_d_to_projection(vector):
"""Take 2D point on manifold and gets its corresponding projection.

INPUT: Point on manifold as a 2x1 vector
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return projection


def submersion(point, k):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this function entirely (it is already coded in geomstats)

return gs.concatenate([row_1, row_2], axis=-2)


def _squared_d_g_a(point_a, point_b, metric):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name this function _squared_dist_grad_point_a for consistency with next funciton

ax.set_zticks([])
plt.show()

def plot_tangent_space(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this method! But follow guidelines for docstring

def plot_tangent_space(self):
"""Plot Grassmanian tangent space.

Warning: Under construction, do not use.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain which case works in details

plt.plot(x_part, y_part, "-g")


class GrassmannianCanonicalMetric(MatricesMetric, RiemannianMetric):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this class entirely. If you need the metric, import it direclty from geomstats:

from geomstats.geometry.grassmannian import GrassmannianCanonicalMetric

"""Test the plotting function of Grassmannian for 2 dimensions."""
self.grassmannian21.plot(True)

def test_plot_2d_render(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the hw's guidelines: the name of the test function should be the same as the name of the function being tests

i.e. rename to test_plot_rendering_2d

The Grassmannian :math:`Gr(n, k)` is the manifold of k-dimensional
subspaces in n-dimensional Euclidean space.

Lead author: Olivier Peltre.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove: the lead author of this file is not Olivier Peltre

@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:17Z
----------------------------------------------------------------

change the name of the ipynb file so that there is no uppercase (everything should be lower case)


@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:18Z
----------------------------------------------------------------

Remove that sentence "The Grassmanian can be expressed in various ways: a set, a differentiable manifold, a set of orthogonal projections, a homogeneous space, or a scheme. One of the most significant qualities of a Grassmannian manifold is that they are an orbit space of the Steifel Manifold v

n

,

k

��,�

 of orthonormal k

 frames in G

n

��

. (Wolfram)"


@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:20Z
----------------------------------------------------------------

Remove this image


@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:21Z
----------------------------------------------------------------

Remove the sentence: "Today, Grassmanian manifolds are applied to computer vision problems such as video-based shape recognition. In computer vision applications, Grassman manifolds are used to compute distances between different images and shapes. "


@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:22Z
----------------------------------------------------------------

Remove that image and the text below.


@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:23Z
----------------------------------------------------------------

Remove this section III, as well as the references it cites (from section on references)


@review-notebook-app
Copy link

review-notebook-app bot commented Feb 13, 2023

View / edit / reply to this conversation on ReviewNB

ninamiolane commented on 2023-02-13T16:47:25Z
----------------------------------------------------------------

Line #8.    # TODO: Change these paths with the corresponding paths on your computer

Remove these lines and the TODO comment

sys.path.append("/home/nmiolane/code/")

sys.path.append("/home/nmiolane/code/ece594n/")

sys.path.append("/home/nmiolane/code/ece594n/hw_geomviz")


matplotlib.use("Agg") # NOQA


class TestVisualizationGrassmanian(tests.conftest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the functions:

  • projection_to_two_d
  • projection_to_three_d
    should be tested as well

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and: two_d_to_projection

from geomstats.geometry.symmetric_matrices import SymmetricMatrices


def projection_to_two_d(projections, points):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a method of the Grassmanian class below + test it in the test file

return np.asarray(storage)


def projection_to_three_d(projections, points):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a method of the Grassmanian class below + test it in the test file

return np.asarray(storage)


def two_d_to_projection(vector):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a method of the Grassmanian class below + test it.

Point.
point_b : array-like, shape=[..., dim]
Point.
metric : SpecialEuclideanMatrixCannonicalLeftMetric
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just say it is a RiemannianMetric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants