elixir-nx / scholar

Traditional machine learning on top of Nx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing key as an option doesn't work

krstopro opened this issue · comments

Runnning the example code

iex> key = Nx.Random.key(42)
iex> x = Nx.tensor([[1, 2], [2, 4], [1, 3], [2, 5]])
iex> Scholar.Cluster.KMeans.fit(x, num_clusters: 2, key: key)
gives me

** (NimbleOptions.ValidationError) unknown options [:key], valid options are: [:num_clusters, :max_iterations, :num_runs, :tol, :weights, :init, :seed] (nimble_options 1.0.2) lib/nimble_options.ex:343: NimbleOptions.validate!/2 (scholar 0.1.0) lib/scholar/cluster/k_means.ex:137: Scholar.Cluster.KMeans.fit/2 #cell:s5a4sk2ajniowihy7hlnzwxvdc773h7d:3: (file)

Perhaps the way key option is declared

key: [
type: {:custom, Scholar.Options, :key, []},
doc: """
Determines random number generation for centroid initialization.
If the key is not provided, it is set to `Nx.Random.key(System.system_time())`.
"""
]
is incorrect?

The key option only exists on main, not on the release v0.1.0. So you need to either use main or follow the docs for v0.1.0 :)

I see, thanks!