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

First commit for Dictionary #948

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

Keanu-Sisouk
Copy link

Thanks for contributing to TTK!

Before submitting your pull request, please:

  • Review our Contributor Guidelines, in particular regarding code formatting (with clang-format) and continuous integration.

  • Please provide a quick description of your contributions below:

Your description here

@Keanu-Sisouk
Copy link
Author

Code corrected for format, lint code and warnings checking

@Keanu-Sisouk Keanu-Sisouk force-pushed the dictionary branch 2 times, most recently from 1e6ac8d to 51db9f0 Compare September 22, 2023 14:17
@julien-tierny
Copy link
Collaborator

Can you please sync to resolve conflicts? Thanks!

@Keanu-Sisouk
Copy link
Author

Branch rebased on ttk-dev and conflicts resolved (the numerical loss returned may change a little bit)

@Keanu-Sisouk
Copy link
Author

Correcting PersistenceDiagramClustering/PDBarycenter.cpp line 346 for Error in Check-Code and Check-Build

Copy link
Collaborator

@julien-tierny julien-tierny left a comment

Choose a reason for hiding this comment

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

hi keanu,
thanks a lot for this PR!
here's a first batch of comments.

  • essentially, they are mostly about naming conventions (for variables and functions, some clever sed -- i.e. find/replace -- should do)
  • a few clarifications regarding Eigen
  • some unnecessary headers to remove
  • so signal creation to remove
  • comments to remove, etc.
    feel free to ping me on slack if you need more info!
    thanks :)

ConstrainedGradientDescent.h
DEPENDS
common
persistenceDiagram
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you need this?
if so, the name of the class may have to be changed.
(if it is specialized for persistence diagrams, the name of the class should reflect it).

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe you'd need to rename it into something like PersistentDiagramConstrainedOptimization

Copy link
Collaborator

Choose a reason for hiding this comment

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

or, you make this class more general (and not specialized to persistence diagram). to discuss I guess.

namespace ttk {
using Matrix = std::vector<std::vector<double>>;

class InitDictPersistenceDiagram : public Debug {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find the name of the class not very explicit.
Words are usually not abbreviated in TTK.
I'd suggest to change the name of the class (and the related files) to something like PersistenceDiagramDictionaryInitializer (PersistenceDictionaryInitializer)

common
persistenceDiagram
persistenceDiagramClustering
persistenceDiagramDistanceMatrix
Copy link
Collaborator

Choose a reason for hiding this comment

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

are all these entries needed? (it's easy to try, just remove these lines and see if it sill works).
I have the impression that the dictionary already depend on the distanceMatrix, so I wonder if these lines are really needed. To try.

std::vector<std::vector<std::array<double, 2>>> &pairToAddGradList,
ttk::DiagramType &infoToAdd);

void setStep(double factEquiv);
Copy link
Collaborator

Choose a reason for hiding this comment

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

-> double &factEquiv (also in the implementation of the function).
use & by default

std::vector<std::vector<std::array<double, 2>>> &pairToAddGradList,
ttk::DiagramType &infoToAdd);

double stepAtom;
Copy link
Collaborator

Choose a reason for hiding this comment

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

-> stepAtom_
for member variables (i.e. member of a class), the convention in ttk is to put an extra _ at the end of the name (to quickly differentiate those from local variables, defined only within functions)

Copy link
Collaborator

Choose a reason for hiding this comment

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

(... except in the specific case of variables directly manipulated by VTK getters and setters)

#include <vtkDoubleArray.h>
#include <vtkFiltersCoreModule.h>
#include <vtkFloatArray.h>
#include <vtkIntArray.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

that include does not seem necessary.
please remove all unnecessary includes (i.e. delete the line and see if it still builds)

double Percent_{0};

public:
// enum class BACKEND{BORDER_INIT = 0 , RANDOM_INIT = 1 , FIRST_DIAGS = 2};
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment if not needed

/// \author Pierre Guillou <[email protected]>
/// \date Mai 2023
///
/// \brief TTK processing package for the computation of a Dictionary
Copy link
Collaborator

Choose a reason for hiding this comment

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

include proper class description.


int FillOutputPortInformation(int port, vtkInformation *info) override;

void outputDiagrams(vtkMultiBlockDataSet *output,
Copy link
Collaborator

Choose a reason for hiding this comment

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

in the VTK layer, the function names should probably match VTK's naming convention (GetOutputDiagrams())

const double spacing,
const double maxPersistence) const;

double getMaxPersistence(const ttk::DiagramType &diagram) const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

in the VTK layer, the function names should probably match VTK's naming convention (cf above), plus, make the function name more explicit.

@julien-tierny
Copy link
Collaborator

hi keanu,
I've been running the example that you prepared for ttk-data (topology-tool-kit/ttk-data#151).
During the iterations of the optimization, it seems that the timing for the substeps is incorrect (always reporting 12 seconds, no mater what). for instance:

[PersistenceDiagramDictionary] Weight Optimization activated
[PersistenceDiagramDictionary] Atom Optimization activated
[PersistenceDiagramDictionary] Minimum not passed273.783325 ..... [12.000s|100%]
[PersistenceDiagramDictionary]  Epoch 32, loss = 273.783325 ..... [12.000s|100%]
[PersistenceDiagramDictionary] Loss returned 206.159905 at Epoch 15
[PersistenceDiagramDictionary] Complete ...................... [0.029s|12T|100%]
[PersistenceDiagramDictionary] New step multi-scale approach:
[PersistenceDiagramDictionary] Weight Optimization activated
[PersistenceDiagramDictionary] Atom Optimization activated
[PersistenceDiagramDictionary] Loss not decreasing enough87 ..... [12.000s|100%]
[PersistenceDiagramDictionary]  Epoch 23, loss = 290.404787 ..... [12.000s|100%]
[PersistenceDiagramDictionary] Loss returned 251.300186 at Epoch 49
[PersistenceDiagramDictionary] Complete ...................... [0.037s|12T|100%]
[PersistenceDiagramDictionary] New step multi-scale approach:
[PersistenceDiagramDictionary] Weight Optimization activated
[PersistenceDiagramDictionary] Atom Optimization activated
[PersistenceDiagramDictionary] Minimum not passed638.536093 ..... [12.000s|100%]
[PersistenceDiagramDictionary]  Epoch 32, loss = 638.536093 ..... [12.000s|100%]
[PersistenceDiagramDictionary] Loss returned 567.337566 at Epoch 71
[PersistenceDiagramDictionary] Complete ...................... [0.197s|12T|100%]
[PersistenceDiagramDictionary] New step multi-scale approach:
[PersistenceDiagramDictionary] Weight Optimization activated
[PersistenceDiagramDictionary] Atom Optimization activated
[PersistenceDiagramDictionary] Loss not decreasing enough174 .... [12.000s|100%]
[PersistenceDiagramDictionary]  Epoch 24, loss = 1064.678174 .... [12.000s|100%]
[PersistenceDiagramDictionary] Loss returned 1052.556453 at Epoch 108
[PersistenceDiagramDictionary] Complete ...................... [0.542s|12T|100%]
[PersistenceDiagramDictionary] Final step multi-scale approach:
[PersistenceDiagramDictionary] Weight Optimization activated
[PersistenceDiagramDictionary] Atom Optimization activated
^[[B[PersistenceDiagramDictionary]  Epoch 14, loss = 1782.946038 .... [12.000s|1[PersistenceDiagramDictionary] Minimum not passed1645.441462 .... [12.000s|100%]
[PersistenceDiagramDictionary]  Epoch 64, loss = 1645.441462 .... [12.000s|100%]
[PersistenceDiagramDictionary] Loss returned 1603.601491 at Epoch 163

also, some undesired debug messages are still visible in the command line:

[PersistenceDiagramDictionary] Complete ..................... [95.281s|12T|100%]
[PersistenceDiagramDictionary] Total time ................... [96.087s|12T|100%]
[PersistenceDiagramDictionaryDecoding] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Atom0
Atom1
Atom2
ClusterID
TimeStep
FILE
[PersistenceDiagramDictionaryDecoding] Computed barycenters .. [2.046s|12T|100%]

Thanks for fixing these (tiny) issues.

Copy link
Collaborator

@julien-tierny julien-tierny left a comment

Choose a reason for hiding this comment

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

here's a few extra comments after running your state file.
thanks!



<!-- Create a UI group that contains all output parameter widgets (here only one) -->
<PropertyGroup panel_widget="Line" label="Input Options">
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are more "Output Options"


<!-- Create a UI group that contains all output parameter widgets (here only one) -->
<PropertyGroup panel_widget="Line" label="Input Options">
<Property name="AtomNumber_" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for listing all the other options here too.
Also:

  • please organize and group them by theme
  • make the labeling convention more uniform (the first word only starts with a capital)
  • remove testing options
  • make the labels more explicit
  • extend the option documentation (<Documentation>...</Documentation>)

<!-- A string parameter that controls the name of the output array -->


<!-- Create a UI group that contains all output parameter widgets (here only one) -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add a category "Output Options" (like for the PersistenceDiagramDictionary filter)


<!-- Create a UI group that contains all output parameter widgets (here only one) -->


Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this filter (at least in principle) depends on some of the parameter values set up during encoding?
(for instance to control the size of the barycenters)
If so, these parameter values should be encoded as field data (and read during decoding)

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

Successfully merging this pull request may close these issues.

2 participants