{"id":16976063,"url":"https://github.com/fwilliams/fml","last_synced_at":"2025-10-25T15:39:36.208Z","repository":{"id":60722429,"uuid":"158792233","full_name":"fwilliams/fml","owner":"fwilliams","description":"FML (Francis' Machine-Learnin' Library) - A collection of utilities for machine learning tasks","archived":false,"fork":false,"pushed_at":"2019-03-21T15:10:22.000Z","size":29,"stargazers_count":35,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T07:41:34.352Z","etag":null,"topics":["chamfer","earth-mover-distance","machine-learning","optimal-transport","point-cloud","pytorch","regularized-optimal-transport","sinkhorn","sinkhorn-distance","wasserstein"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fwilliams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-23T06:50:04.000Z","updated_at":"2025-03-16T11:51:02.000Z","dependencies_parsed_at":"2022-10-03T21:01:27.040Z","dependency_job_id":null,"html_url":"https://github.com/fwilliams/fml","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fwilliams/fml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Ffml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Ffml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Ffml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Ffml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fwilliams","download_url":"https://codeload.github.com/fwilliams/fml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Ffml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003892,"owners_count":26083641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chamfer","earth-mover-distance","machine-learning","optimal-transport","point-cloud","pytorch","regularized-optimal-transport","sinkhorn","sinkhorn-distance","wasserstein"],"created_at":"2024-10-14T01:24:48.999Z","updated_at":"2025-10-10T12:35:25.544Z","avatar_url":"https://github.com/fwilliams.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"FML (Francis' Machine-Learnin' Library)\n===================================\n\nThis repository is a collection of PyTorch tools for machine learning. Currently it includes \n* A numerically stable implementation of the [Sinkhorn Algorithm](https://arxiv.org/abs/1306.0895) for point sets in any dimension\n* A vectorized implementation of the Chamfer Distance between point sets in any dimension\n\n## Installation Instructions\n\n### With conda (recommended)\nOn Linux, Simply run:\n```\nconda install -c conda-forge fml\n```\n\nOn Windows and Mac, you may need to add the PyTorch Channel before installing:\n```\nconda config --add channels pytorch\nconda install -c conda-forge fml\n```\n\n### With pip (not recommended)\nSimply run:\n```\npip install git+https://github.com/fwilliams/fml\n```\n\n\n\n## Library Structure\nThe structure of the library is similar to PyTorch. There is a `fml.functional` module which includes a functional interface for utilities and an `fml.nn` which includes PyTorch module implementations of utilities.\n\n## Examples\n\n### Computing the loss between two evenly weighted point sets\n```python\nimport torch\nfrom fml.nn import SinkhornLoss\n\nminibatch_size = 3\nset_size = 10\npoint_dim = 4\n\n# Create two minibatches of point sets where each batch item set_a[k, :, :] is a set of `set_size` points\nset_a = torch.rand([minibatch_size, set_size, point_dim])\nset_b = torch.rand([minibatch_size, set_size, point_dim])\n\n# Create a loss function module with default parameters. See the class documentation for optional parameters.\nloss_fun = SinkhornLoss()\n\n# Compute the loss between each pair of sets in the minibatch\n# loss is a tensor with [minibatch_size] elements which can be backpropagated through\nloss = loss_fun(set_a, set_b)\n```\n\n### Computing the loss between two non evenly weighted point sets\n```python\nimport torch\nfrom fml.nn import SinkhornLoss\n\nminibatch_size = 3\nset_size = 10\npoint_dim = 4\n\n# Create two minibatches of point sets where each batch item set_a[k, :, :] is a set of `set_size` points\nset_a = torch.rand([minibatch_size, set_size, point_dim])\nset_b = torch.rand([minibatch_size, set_size, point_dim])\n\n# Generate weights which sum to 1 for each set\n# Note that zero weights are the same as not including a set element\nweights_a = torch.rand([minibatch_size, set_size])\nweights_a /= torch.sum(weights_a, axis=1) \n\nweights_b = torch.rand([minibatch_size, set_size])\nweights_b /= torch.sum(weights_b, axis=1) \n\n# Create a loss function module with default parameters. See the class documentation for optional parameters.\nloss_fun = SinkhornLoss()\n\n# Compute the loss between each pair of sets in the minibatch\n# loss is a tensor with [minibatch_size] elements which can be backpropagated through\nloss = loss_fun(set_a, set_b)\n```\n\n\n### Computing the Chamfer Distance between point sets\n```python\nimport torch\nfrom fml.nn import ChamferLoss\n\nminibatch_size = 3\nset_size = 10\npoint_dim = 4\n\n# Create two minibatches of point sets where each batch item set_a[k, :, :] is a set of `set_size` points\nset_a = torch.rand([minibatch_size, set_size, point_dim])\nset_b = torch.rand([minibatch_size, set_size, point_dim])\n\n# Create a loss function module.\nloss_fun = ChamferLoss()\n\n# Compute the loss between each pair of sets in the minibatch\n# loss is a tensor with [minibatch_size] elements which can be backpropagated through\nloss = loss_fun(set_a, set_b)\n```\n\n### Computing pairwise distances between point sets\n```python\nimport torch\nfrom fml.functional import pairwise_distances\n\nminibatch_size = 3\nset_size = 10\npoint_dim = 4\n\n# Create two minibatches of point sets where each batch item set_a[k, :, :] is a set of `set_size` points\nset_a = torch.rand([minibatch_size, set_size, point_dim])\nset_b = torch.rand([minibatch_size, set_size, point_dim])\n\n# Compute the pairwise distances between each pair of sets in the minibatch\n# distances is a tensor of shape [minibatch_size, set_size, set_size] where each\n# disances[k, i, j] = ||set_a[k, i] - set_b[k, j]||^2\ndistances = pairwise_distances(set_a, set_b)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwilliams%2Ffml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffwilliams%2Ffml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwilliams%2Ffml/lists"}