Skip to content

Commit

Permalink
latest changes!
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingWorkshop committed Mar 7, 2024
1 parent 0a6ec53 commit e71e4aa
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 5 deletions.
4 changes: 3 additions & 1 deletion demos/basic_usage.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Revise

using ExpFamilyPCA


Expand All @@ -7,7 +9,7 @@ X = rand(0:1, n_samples, n_dims) # generate random binary data

n_components = 2
epca = BernoulliPCA(n_components, n_dims)
fit!(epca, X; verbose=true, maxiter=30)
fit!(epca, X; verbose=true, maxiter=5)

= compress(epca, X)
X_recon = decompress(epca, X̃)
4 changes: 2 additions & 2 deletions demos/bernoulli_benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.1",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.1"
"version": "1.10.2"
}
},
"nbformat": 4,
Expand Down
81 changes: 81 additions & 0 deletions demos/kl_benchmark.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m No Changes\u001b[22m\u001b[39m to `~/VSCodeProjects/BeliefCompression/ExpFamilyPCA/Project.toml`\n",
"\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/VSCodeProjects/BeliefCompression/ExpFamilyPCA/Manifest.toml`\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" \u001b[90m[7d9fca2a] \u001b[39m\u001b[92m+ Arpack v0.5.4\u001b[39m\n",
" \u001b[90m[6f286f6a] \u001b[39m\u001b[92m+ MultivariateStats v0.10.2\u001b[39m\n",
" \u001b[90m[08074719] \u001b[39m\u001b[91m- POMDPModelTools v0.3.13\u001b[39m\n",
" \u001b[90m[e0d0a172] \u001b[39m\u001b[91m- POMDPSimulators v0.3.14\u001b[39m\n",
"\u001b[33m⌅\u001b[39m \u001b[90m[68821587] \u001b[39m\u001b[92m+ Arpack_jll v3.5.1+1\u001b[39m\n",
"\u001b[36m\u001b[1m Info\u001b[22m\u001b[39m Packages marked with \u001b[33m⌅\u001b[39m have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`\n"
]
}
],
"source": [
"using Pkg\n",
"# Pkg.develop(\"CompressedBeliefMDPs\")\n",
"# Pkg.develop(\"ExpFamilyPCA\")\n",
"Pkg.resolve()\n",
"\n",
"using CompressedBeliefMDPs\n",
"using ExpFamilyPCA\n",
"\n",
"using POMDPs\n",
"using POMDPModels\n",
"using POMDPTools"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "UndefVarError",
"evalue": "UndefVarError: `TMaze` not defined",
"output_type": "error",
"traceback": [
"UndefVarError: `TMaze` not defined\n",
"\n",
"Stacktrace:\n",
" [1] top-level scope\n",
" @ ~/VSCodeProjects/BeliefCompression/ExpFamilyPCA/demos/kl_benchmark.ipynb:1"
]
}
],
"source": [
"pomdp = TMaze(50, 0.99)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
4 changes: 2 additions & 2 deletions demos/poisson_benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -483,15 +483,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.1",
"display_name": "Julia 1.10.2",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.1"
"version": "1.10.2"
}
},
"nbformat": 4,
Expand Down
4 changes: 4 additions & 0 deletions src/ExpFamilyPCA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ export
BernoulliPCA
include("bernoulli.jl")

export
GaussianPCA
include("gaussian.jl")


end # module ExpFamilyPCA
8 changes: 8 additions & 0 deletions src/gaussian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function GaussianPCA(l::Integer, d::Integer; μ0::Real=0)
@. begin
g(θ) = θ
Bregman(p, q) = (p - q)^2 / 2
end
epca = EPCA(l, d, g, Bregman, μ0)
return epca
end

0 comments on commit e71e4aa

Please sign in to comment.