zacksiri
Hey everyone.
So i’ve been developing a model and it started as a straightforward logistic regression model and has evolved into a multi input / multi output model.
Here is what the model looks like
def model do
# Create three input tensors for CPU, Memory, and Disk
input_cpu = Axon.input("cpu", shape: {nil, 2})
input_memory = Axon.input("memory", shape: {nil, 3})
input_disk = Axon.input("disk", shape: {nil, 2})
# Create separate prediction paths for each resource
cpu_prediction =
Axon.dense(input_cpu, 2, activation: :sigmoid, name: "cpu")
memory_prediction =
input_memory
|> Axon.dense(8, activation: :relu)
|> Axon.dense(2, activation: :sigmoid, name: "memory")
disk_prediction =
Axon.dense(input_disk, 2, activation: :sigmoid, name: "disk")
# Combine outputs into a single model with multiple outputs
Axon.container(
%{
cpu: cpu_prediction,
memory: memory_prediction,
disk: disk_prediction
},
name: "results"
)
end
Here is what the training loop looks like:
def train(data, opts \\ []) do
save? = Keyword.get(opts, :save, false)
model = model()
state = Keyword.get(opts, :state) || Axon.ModelState.empty()
iterations = Keyword.get(opts, :iterations, 100)
epochs = Keyword.get(opts, :epochs, 100)
# Losses and weights for each output cpu, memory, disk
losses = [binary_cross_entropy: 0.2, binary_cross_entropy: 0.4, binary_cross_entropy: 0.4]
state =
model
|> Axon.Loop.trainer(losses, Polaris.Optimizers.adamw(learning_rate: 0.01))
|> Axon.Loop.run(data, state, iterations: iterations, epochs: epochs)
if save? do
dump_state(state)
end
state
end
I’ve tried the following data structures:
training_data = [
# Example 1: Good placement (plenty of resources)
{
%{
"cpu" => Nx.tensor([[0.05, 0.825]]), # [requested, available]
"memory" => Nx.tensor([[0.0625, 0.65, 0.10]]),
"disk" => Nx.tensor([[0.004, 0.55]])
},
%{
cpu: Nx.tensor([[1.0, 0.0]]), # Good placement
memory: Nx.tensor([[1.0, 0.0]]), # Good placement
disk: Nx.tensor([[1.0, 0.0]]) # Good placement
}
},
# Example 2: Bad placement (scarce resources)
{
%{
"cpu" => Nx.tensor([[0.05, 0.12]]), # Low available CPU
"memory" => Nx.tensor([[0.0625, 0.15, 0.010]]), # Low available memory
"disk" => Nx.tensor([[0.004, 0.10]]) # Low available disk
},
%{
cpu: Nx.tensor([[0.0, 1.0]]), # Bad placement
memory: Nx.tensor([[0.0, 1.0]]), # Bad placement
disk: Nx.tensor([[0.0, 1.0]]) # Bad placement
}
}
]
training_data = [
# Example 1: Good placement
{
{
Nx.tensor([[0.05, 0.825]]),
Nx.tensor([[0.0625, 0.65, 0.010]]),
Nx.tensor([[0.004, 0.55]])
},
{
Nx.tensor([[1.0, 0.0]]),
Nx.tensor([[1.0, 0.0]]),
Nx.tensor([[1.0, 0.0]])
}
},
# Example 2: Bad placement
{
{
Nx.tensor([[0.05, 0.12]]),
Nx.tensor([[0.0625, 0.15, 0.010]]),
Nx.tensor([[0.004, 0.10]])
},
{
Nx.tensor([[0.0, 1.0]]),
Nx.tensor([[0.0, 1.0]]),
Nx.tensor([[0.0, 1.0]])
}
}
]
# Correct training data structure with properly shaped tensors
training_data = [
# Each training example
{
# Inputs tuple
{
Nx.tensor([0.05, 0.825]), # cpu - shape {2}
Nx.tensor([0.0625, 0.65, 0.010]), # memory - shape {2}
Nx.tensor([0.004, 0.55]) # disk - shape {2}
},
# Targets tuple
{
Nx.tensor([1.0, 0.0]), # cpu target - shape {2}
Nx.tensor([1.0, 0.0]), # memory target - shape {2}
Nx.tensor([1.0, 0.0]) # disk target - shape {2}
}
}
]
None of the above examples seem to work. Any suggestions?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zacksiri
I managed to figure out where I went wrong.
The
Axon.containeris wrong. The output format needs to be a tuple not a mapSo this is invalid
Then the training data set should look like the following:
I am now able to start the training loop. I have no one but myself to blame. I followed Claude down a rabbit hole. I was very happy with my simple logistic regression model.
Then I went to ask it how split the output into cpu, memory, disk instead of just having a single output, and it gave me the model you see above. In it’s defense most of the model was correct the only part that’s wrong is the
Axon.containerbit. But my lack of experience naively thought it would work.