jihunhamm / crowd-ml Goto Github PK
View Code? Open in Web Editor NEWFramework for Crowd-sourced Machine Learning
License: Apache License 2.0
Framework for Crowd-sourced Machine Learning
License: Apache License 2.0
Wifi on a physical device goes down for a few seconds and the weightIter
resets to 0 before ever hitting the update weights. A new checkForWifi
method should be implemented.
Currently only inference is supported from Tensorflow on Android devices. The Android demo uses the very basic Tensorflow Java API which does not support training (only the python API supports sophisticated training). However, this C++ example shows that training in languages other than python is not impossible. I think using this reference for manual backpropagation will be useful in the future.
Edit March 10, '17:
After some continued research by me and David Soller (@3ygun) we have found a great resource about training models in C++. The great part about this article is that it has convinced me that training is possible simply from the Tensorflow Java API with slight modification (see link above). The models will need to be pre-generated from python code, and then loaded onto the device (or downloaded from the server). The only requirement is that there should be a named operation for training in the model.
Line 14 in training models in C++ shows this named operation:
optimizer = tf.train.AdamOptimizer().minimize(cost, name="train")
He runs this operation on line 41 in the C++ code block:
TF_CHECK_OK(session->Run({{"x", x}, {"y", y}}, {}, {"train"}, nullptr)); // Train
I believe the above line can be achieved purely from the Java API, so I'm changing the status to 'plausible'.
There is an issue when restarting either the client or the server while the other is running.
Weight iteration mismatch(working in issue13 branch):
Run client and server for any amount of time so that the weight iteration
increases by some multiple of localUpdateNum.
Close down the client completely (red stop button in Android Studio).
Reopen client, and view the mismatched weight iteration between the server and
the client.
Client can't restart after a server restart (working in issue13 branch):
Run client and server for any amount of time.
Close down the server.
Restart the server and view the client never continuing to run iterations.
EDIT: I'm currently doing more testing to confirm that my solutions are stable. A PR will be made soon.
Steps to reproduce:
Open up client, and make sure service is running
Make sure server is not running. If it is, close it down to ensure no processing on the client is happening.
Open the Android monitor and select the crowd-ml:datasend process. View the allocated memory continuously increasing in the performance profiler.
This may be due to the wifi listener, because that is the only running thread in the :datasend process.
Make the WiFi handling more robust and fix #24 and #15
CONNECTIVITY_ACTION
isActiveNetworkMetered
It's not training.
In the TensorFlowTrainer.java
replace:
// Copy the weights Tensor into the weights array.
Trace.beginSection("fetch");
trainingInterface.fetch(weightsOp, w);
Trace.endSection();
with:
float[] w_new = new float[D * K];
// Copy the weights Tensor into the weights array.
Trace.beginSection("fetch");
trainingInterface.fetch(weightsOp, w_new);
Trace.endSection();
int z = 0;
boolean equal = true;
for (int x=0; x<D*K && equal; x++) {
if (Math.abs(w[x])-Math.abs(w_new[x]) > 0.0005) {
z = x;
equal = false;
}
}
Log.d(" ", " ");
Log.d("Weights Equal", "" + w.equals(w_new));
Log.d("Original Weights", ""+w[0]+" "+w[1]+" "+w[2]);
Log.d("New Weights", ""+w[0]+" "+w[1]+" "+w[2]);
Log.d(" ", "");
w = w_new;
And look at the log debug with weights aren't changing between runs only the data we run the initial random weights against which explains why we're not getting >20% accuracy.
When I try to run crowdML-server-Android.js (master branch), I get the following error:
Error: Firebase.update failed: First argument contains undefined in property 'parameters.maxIter
If you look at line 30 in crowdML-server-Android.js it is looking for the maxIter variable
30| var maxIter = constants.maxIter;
However this variable is not present in any of the Constants.js files. Should this variable be removed from the server file or added to the constants file?
Setting the localUpdateNum to a value, say 10, can greatly increase computation speeds and I would highly recommend this for testing purposes. However, setting the localUpdateNum to high values (I tried 100 EDIT: Also fails for values >=15) will cause an IndexOutOfBoundsException ~line 433. See below for the code block.
From the internalWeightCalc method:
while(dataCount > 0 && batchSlot < batchSize) {
// This is the problem line
batchSamples.add(order.get((batchSize*localUpdateNum*(dataCount-1) + batchSlot*(localUpdateIter+1))));
batchSlot++;
}
If anyone could help explain the calculation on line 3 above that would be much appreciated. Does this try to get random samples from the batchSamples list?
The error I got (for 100) was:
java.lang.IndexOutOfBoundsException: Index: 99900, Size: 12665
Note that 12665 is the size of the binary classification data.
Please checkout the issue8 branch before testing.
Server ran with:
node crowdML-server-Android.js Constants1.js
Constants1.js is the constants file for binary classification.
trainingInterface.fetch(weightsOp, w);
This line of code is working??????
I got error like " Node weightsOp was not provided to run(), so it cannot be read.
Also, I have one more question. where can I get the TensorflowTrainingInterface.java??
I got the file from another project though.. I want to know the right one.
Make the project more maintainable.
.zip
file with all of the .dat
/similar files in a directory which is zipped e6d8ed3Allow for the Android app to use any TensorFlow model with a supplied configuration file for retrieving the weights and biases. (Most of the big points on #28)
Complete #32 basic TensorFlow in the app
Add ability for server to supply the fields to get the weight values trainable parameters
Add ability for app to get & send all the fields supplied by the server
Test that everything is happening
Supply a program (set of python methods) to CrowdML supervisors that will populate the .json
configuration data needed
def generateCrowdMLTFConfig(session):
...
Use TensorFlow for model back-ends to enable better extensibility. This issue will server as a base of operations regarding the progress and/or discussion around the implementation.
@tylermzeller and I believe the following would be some of the required implementation plan to enable the above goal:
NOTE: most of these can be explored through desktop TensorFlow applications
Single app
vs Library
The android server is only present in the master branch, and it works correctly as far as I know. However, to test the Android client, you need to first switch to Jackson's branch because that is the only branch whose Android code will compile.
Things I will be working on:
See InternalServer.java There is no implementation for adagrad or rmsProp descent algorithms. This will crash the app if these options are chosen in the Constants.js files.
// TODO: Why are learningRateDenom and eps not used?
public static List<Double> calcWeight(List<Double> oldWeights, List<Double> learningRateDenom, List<Double> grad, float t, String descentAlg, double c, double eps){
List<Double> newWeight = new ArrayList<>(oldWeights.size());
if(descentAlg.equals("constant")){
for(int i = 0; i < oldWeights.size(); i ++){
newWeight.add(oldWeights.get(i) - (c)*grad.get(i));
}
}
if(descentAlg.equals("simple")){
for(int i = 0; i < oldWeights.size(); i ++){
newWeight.add(oldWeights.get(i) - (c/t)*grad.get(i));
}
}
if(descentAlg.equals("sqrt")){
for(int i = 0; i < oldWeights.size(); i ++){
newWeight.add(oldWeights.get(i) - (c/Math.sqrt(t))*grad.get(i));
}
}
// No support for adagrad or rmsProp
return newWeight;
}
Whenever I login to the Android client, there is a crash. @FrankHYB has pointed out that the crash originates from the DataSend.java class. I did some investigation into the problem and it appears that when the client attempts to receive the weights from the Firebase db, the data the java code expects is different from the actual data stored in Firebase.
This is what the weights tree looks like in my Firebase db. If you expand the first child, thousands of weight values appear. If you expand the second branch, a 1 and a -1 appear.
Looking in the Android server see starting on line 238:
if(localUpdateNum > 0){
iter += localUpdateNum;
} else {
iter++;
}
My question is how the server can support multiple devices if the server only keeps track of a single weight iteration?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.