Skip to content

Commit

Permalink
started refactor to remove redundant calls
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingWorkshop committed Feb 27, 2024
1 parent eb9da75 commit d00f40a
Show file tree
Hide file tree
Showing 7 changed files with 490 additions and 92 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "1.0.0-DEV"

[deps]
CompressedBeliefMDPs = "0a809e47-b8eb-4578-b4e8-4c2c5f9f833c"
Infiltrator = "5903a43b-9cc3-4c30-8d17-598619ec4e9b"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
4 changes: 2 additions & 2 deletions demos/basic_usage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ using ExpFamilyPCA


n_samples = 5
n_dims = 10
n_dims = 100
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=10)
fit!(epca, X; verbose=true, maxiter=30)

= compress(epca, X)
X_recon = decompress(epca, X̃)
79 changes: 5 additions & 74 deletions demos/benchmark.ipynb → demos/bernoulli_benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,17 @@
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loss: 346.57359027997245\n",
"Loss: "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"339.4651260162266\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loss: 326.83851096508596\n",
"Loss: "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"313.16798822607956\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loss: 300.47024994515317\n",
"Loss: "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"287.68813149707574\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loss: 278.5198879020468\n",
"Loss: "
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"272.07194894059666\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loss: 267.2032539001495\n",
"Loss: "
]
}
],
"outputs": [],
"source": [
"using ExpFamilyPCA\n",
"\n",
"n_samples = 10\n",
"n_dims = 5\n",
"n_samples = 5\n",
"n_dims = 100\n",
"X = rand(0:1, n_samples, n_dims) # generate random binary data\n",
"\n",
"n_components = 2\n",
"n_components = 5\n",
"epca = BernoulliPCA(n_components, n_dims)\n",
"fit!(epca, X; verbose=true, maxiter=10)\n",
"\n",
Expand Down
125 changes: 125 additions & 0 deletions demos/custom_epca.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-538.7928326875457\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-692.9406810373927\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0129701762987\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.030579782313\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0312855390176\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0321656858174\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.033504639585\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0344314484549\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0355052008783\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0367590091735\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0383085993361\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"-693.0395117451338\n"
]
}
],
"source": [
"using ExpFamilyPCA\n",
"\n",
"n_samples = 10\n",
"n_dims = 20\n",
"X = rand(n_samples, n_dims) # generate fake probability data\n",
"X ./= sum(X, dims=2)\n",
"\n",
"n_components = 2\n",
"epca = EPCA(n_components, n_dims, x->exp(x), 1)\n",
"fit!(epca, X; verbose=true, maxiter=20)\n",
"\n",
"X̃1 = compress(epca, X)\n",
"recon1 = decompress(epca, X̃1)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.1",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit d00f40a

Please sign in to comment.