Skip to content

Commit

Permalink
spinrbm, devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
cossio committed Mar 20, 2024
1 parent 5a5eede commit f347e4a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true,
"nonFreePackages": true
}
},
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions",
"ms-toolsai.jupyter",
"tamasfe.even-better-toml",
"julialang.language-julia"
],
"settings": {
"julia.executablePath": "~/.juliaup/bin/julia"
}
}
},
"onCreateCommand": "bash .devcontainer/onCreate.sh"
}
2 changes: 2 additions & 0 deletions .devcontainer/julia_startup.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ENV["JULIA_PKG_USE_CLI_GIT"] = true
ENV["JULIA_PKG_SERVER_REGISTRY_PREFERENCE"] = "eager"
11 changes: 11 additions & 0 deletions .devcontainer/onCreate.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Pkg

Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/cossio/CossioJuliaRegistry.git"))
Pkg.Registry.add("General")

Pkg.add([
"CairoMakie",
"Makie",
"MyRegistrator",
"Revise",
])
18 changes: 18 additions & 0 deletions .devcontainer/onCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# install Julia and make sure it's in the PATH of the current shell
curl -fsSL https://install.julialang.org | sh -s -- --yes

# Julia startup file
mkdir -p ~/.julia/config
cp .devcontainer/julia_startup.jl ~/.julia/config/startup.jl

# Github CLI autocomplete (https://www.ajfriesen.com/github-cli-auto-completion-with-oh-my-zsh/)
mkdir -p ~/.oh-my-zsh/completions
/usr/bin/gh completion -s zsh > ~/.oh-my-zsh/completions/_gh
echo "autoload -U compinit" >> ~/.zshrc
echo "compinit -i" >> ~/.zshrc

# Directory to store Rfam data (set in LocalPreferences.toml)
mkdir -p ~/data/Rfam

# Install Julia packages, registries, ...
/home/vscode/.juliaup/bin/julia .devcontainer/onCreate.jl
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RestrictedBoltzmannMachines"
uuid = "12e6b396-7db5-4506-8cb6-664a4fe1e50e"
authors = ["Jorge Fernandez-de-Cossio-Diaz <[email protected]>"]
version = "3.3.1-DEV"
version = "3.4.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
1 change: 1 addition & 0 deletions src/RestrictedBoltzmannMachines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ include("rbm.jl")

include("rbms/hopfield.jl")
include("rbms/binary.jl")
include("rbms/spin.jl")
include("rbms/gaussian.jl")

include("pseudolikelihood.jl")
Expand Down
15 changes: 15 additions & 0 deletions src/rbms/spin.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function SpinRBM(a::AbstractArray, b::AbstractArray, w::AbstractArray)
@assert size(w) == (size(a)..., size(b)...)
visible = Spin(; θ = a)
hidden = Spin(; θ = b)
return RBM(visible, hidden, w)
end

function SpinRBM(::Type{T}, N::Union{Int,Dims}, M::Union{Int,Dims}) where {T}
a = zeros(T, N...)
b = zeros(T, M...)
w = zeros(T, N..., M...)
return SpinRBM(a, b, w)
end

SpinRBM(N::Union{Int,Dims}, M::Union{Int,Dims}) = SpinRBM(Float64, N, M)

0 comments on commit f347e4a

Please sign in to comment.