Skip to content

The generic framework for solving approximate inference problem with BP #11

Closed

Description

@GiggleLiu

Activity

  1. added this to the v0.1: wme milestone on Jan 17, 2026
  2. Morningliumengkun commented on Jan 17, 2026

    @Morningliumengkun
    Collaborator

    PyTorch Belief Propagation Implementation Plan

    1. Core Objectives

    1. Implement a generic Belief Propagation (BP) algorithm using PyTorch
    2. Provide comprehensive mathematical description and code documentation

    2. Technical Analysis

    2.1 Algorithm Flow

    Algorithm Flow: Initialize → Collect Messages → Process Messages → Damping Update → Convergence Check → Compute Marginals

    2.2 Function Interface Summary

    Function Name Functionality Input Output
    read_model_file Parse UAI file filepath UAIModel
    read_evidence_file Parse evidence file filepath Dict[int, int]
    BeliefPropagation.__init__ Construct BP object UAIModel BP object
    initial_state Initialize messages BP object BPState
    collect_message Factor→Variable message BP, BPState None
    process_message Variable→Factor message BP, BPState, damping None
    belief_propagate BP main loop BP, parameters (BPState, BPInfo)
    compute_marginals Compute marginal probabilities BPState, BP Dict[int, Tensor]
    apply_evidence Apply evidence BP, evidence BeliefPropagation

    3. Project Structure and Testing

    3.1 Project Structure

    pytorch_bp_inference/
    ├── README.md
    ├── requirements.txt
    ├── setup.py (optional)
    ├── src/
    │   ├── __init__.py
    │   ├── uai_parser.py          # UAI file parsing
    │   ├── belief_propagation.py  # BP core implementation
    │   └── utils.py               # Utility functions
    ├── tests/
    │   ├── __init__.py
    │   ├── test_uai_parser.py
    │   ├── test_bp.py
    │   └── test_integration.py
    ├── examples/
    │   ├── asia_network/
    │   │   ├── main.py
    │   │   └── model.uai
    │   └── simple_example.py
    └── docs/
        ├── mathematical_description.md
        ├── api_reference.md
        └── usage_guide.md
    

    3.2 Testing

    • Test parsing examples/asia-network/model.uai
    • Test BP initialization and state creation
    • Test message collection and processing
    • Test convergence checking
    • Test marginal computation
    • Test evidence application
    • Compare results with provided reference results
  3. GiggleLiu commented on Jan 17, 2026

    @GiggleLiu
    MemberAuthor

    Make this belief propagation framework a submodule, instead of an independent package.

  4. GiggleLiu commented on Jan 19, 2026

    @GiggleLiu
    MemberAuthor

    Resolved by #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions