Repository navigation
Conversation
|
example code to check in SC: |
| if (!srcPtr) return Error(NoDataSet); | ||
| auto dataSet = srcPtr->getDataSet(); | ||
| if (dataSet.size() == 0) return Error(EmptyDataSet); | ||
| if (dataSet.size() != get<kNumClusters>()) return Error(WrongNumInitial); |
There was a problem hiding this comment.
Presumably the numClusters parameter can now be incorrect after setMeans. So this method actually needs to update the params and return these.
Something like (untested)
MessageResult<ParamValues> setMeans(InputDataSetClientRef srcClient)
{
auto srcPtr = srcClient.get().lock();
if (!srcPtr) return Error(NoDataSet);
auto dataSet = srcPtr->getDataSet();
if (dataSet.size() == 0) return Error(EmptyDataSet);
auto numClusters = dataSet.size();
mAlgorithm.setMeans(dataSet.getData());
// update params and return to host
ParamValues newParams = mParams.get().toTuple();
std::get<kNumClusters>(newParams) = numClusters;
return newParams;
}There was a problem hiding this comment.
ParamValues will need to be defined near the top of the class, like in the MLP objects:
using ParamValues = typename ParamSetViewType::ValueTuple;There was a problem hiding this comment.
this is interesting, as the current public code does not behave the way I thought it would - changing the numCluster should always reset the algo to unFitted, but it currently doesn't.
could we fix that the same way? In effect, the expected behaviour for me:
- set does what I did here
- changing numCluster always invalidates the fitting (it doesn't now)
should i just put a separate bug report and a fix for that? Or am I just all confused?
There was a problem hiding this comment.
studying MLP code, I can see that the clients check if (!mAlgorithm.trained()) return Error(NoDataFitted); but i cannot find how it makes it 'untrained' when any parameter (like network structure) is changed. mTracker is only checked once in fit.
There was a problem hiding this comment.
an example of the misunderstood behaviour by yours truly:
----------begin_max5_patcher----------
1884.3oc0ZksbihCE8YmuBU7raWrujm546nyTtjAYa0AKwHDwISWc+sOZCLf
gDCMwS09ABn064bWzUR4GOrxZG8UToE3Qv2.qV8iGVsRUjrfUluWYcB9ZZNr
T0LqT5oSHB2ZstNN5UtpbmMfSvmQ.HvGTPwDNHq7Ih6FPACkgS4OBPLFksFP
nbvdLmiXOQ71He8Ih+FvYJ6YQGB1.xomQL.o5TZdUopYga.kbbdttQqAnWPD
.dOn7HsJ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4540oV35M8KHo
MlU8pa51ZJnedcFh3p74RZmN2Hox4dIStqn5acdhuSyi6MLOprzc9MmHG+6D
hbBtWST38Zhb07+6qjVpIx9dLQd2vDE0oMmvY5ybu9+gG0ox4Xq+uaHo4ieS
IK5VXfqUp53J8teQ4bz6dE6cmhWeehieWh8uGQUhUic+gO7yG9OP.s.FO
-----------end_max5_patcher-----------
There was a problem hiding this comment.
load and read have absolutely horrible special case handling in the host wrappers that happens to deal with updating the parameters. There's not any machinery for ad hoc messages that would return updated parameters (like setMeans).
There was a problem hiding this comment.
When I say it works, I mean that I have a debugger with the process and I go line for line, I see in all cases the mAlgo being changed, and the newParams too. the only diff is in the 'updated' client - one updates, the other not.
There was a problem hiding this comment.
Yes. It will 'work', but only up to the point where the host needs to actually store the updated parameters, which it won't do without a new overload being added.
There was a problem hiding this comment.
ok so should I put a bug report for load/read not working for kmeans, or will sorting this PR sort the other case too?
There was a problem hiding this comment.
load and read not working is its own issue, though I suspect it's because the default implementation for data clients doesn't return updated parameters (MLP overrides the default).
Co-authored-by: Owen Green <gungwho@gmail.com>
fixes #120
I removed the nonsensical condition, and added 2 asserts to make sure we get the right values passed, assuming that a dataset with at least one point will have the right type. Maybe @weefuzzy will want to change the checking - I also thought of checking that the passed info was a vector of float instead of the asserts, and maybe that would be better. I'm opened to suggestions.