GithubHelp home page GithubHelp logo

mccorby / photolabellerserver Goto Github PK

View Code? Open in Web Editor NEW
50.0 4.0 13.0 82 KB

Federated Learning: Parameter Server doing aggregation of updates to a model coming from clients participating in a Federated Learning setup. See also the Android application companion at https://github.com/mccorby/PhotoLabeller

License: MIT License

Kotlin 88.18% Java 11.82%
machine-learning federated-learning kotlin dl4j deeplearning4j cifar-10

photolabellerserver's Introduction

Federated Learning. The server side bit

This project works in conjunction with the Photo Labeller Android app

The server is in charge of the following tasks:

  • Create an initial model
  • Control the training rounds: when to open and close them
  • Do the update of the model once a round is finished using the info uploaded by the clients

Installation instructions

Use IntelliJ to build the project

The server expects a local.properties file to provide some information

Example:

model_dir = some_directory_in_your_local_machine
# In milliseconds. 24 hours
time_window = 86400000
min_updates = 1000
layer_index = 3

This file must be located in the server module at the same level as the build.gradle file

Training the initial model and testing it

To run the initial model training, use the Main.kt file

The training process expects three arguments:

  • train string to trigger the process
  • A valid directory to save the resulting model
  • The third optional argument can be web to start the UI monitor provided by DL4J

You can also run a prediction to test your model. The expected arguments are:

  • Location of the model
  • Location of an image to classify

Running the Federated Parameter Server

The server is in charge of starting the training rounds and to keep the updates sent by the clients until the shared model has been updated

The training round starts when the server is initialised. In a real life system, the training round would be triggered either automatically or manually by someone

Execute the JobQueueServer main method and the server will be up and running

The REST API is quite simple:

  • GET model to get the latest shared model in this server
  • POST model to upload the updates from the clients
  • GET round to obtain the info about the current round

To check that the server is up and running in your local installation, hit this URL

http://localhost:9997/service/federatedservice/available

Flow of an open round

  • Make sure the server has opened a new round. This can be checked at http://localhost:9997/service/federatedservice/currentRound If the round is not opened yet, this service will create a new one with the following JSON format
{
    "modelVersion": "round_20181007_080305",
    "startDate": 1538895785617,
    "endDate": 1538982185617,
    "minUpdates": 1000
}
  • Client update is received

When a client sends the update to the model, this is stored by the server in the current round directory

The update is also cached in memory to help with the post process

  • Closing the round and updating the model

A training round can be closed by reaching the minimum number of clients updates or by timing out

Once the round is closed, the updates are processed by using the UpdatesStrategy injected in the server. The current implementation of this strategy performs a Federated Averaging

The model is then updated (actually just the last feature layer) and saved. From this moment this is considered the latest version of the shared model

All client updates are deleted so that no trace of them remains in the server

photolabellerserver's People

Contributors

jacorbachosky avatar mccorby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

photolabellerserver's Issues

FederatedAveragingStrategy

In FederatedAveragingStrategy class processSingleUpdate function,why the normalisedUpdate equals to update div normaliser?
normaliser=samples/totalsamples
normalisedUpdate=update/normaliser=update*totalsamples/samples?
I can't understand here.Are you using the FedAvg algorithm?

Can not show UI and predict

Hi, I'm a student interest in Federated Learning.

I ran the client program and there was no problem, and the model also can return to the server-side
When I ran server-side,
http://localhost:9997/service/federatedservice/available can run,
but there wasn't show UI on the web.

And I ran PhotoLabellerServer/model/src/main/kotlin/com/mccorby/photolabeller/ml/Main.kt,
the compiler showed

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
	at com.mccorby.photolabeller.ml.MainKt.main(Main.kt:42)]

Process finished with exit code 1

I tried to find the solution for a long time, but I still not understand where is the problem,

Has anyone solved it?

Thanks!

DataSet

The following is not actually an issue, but would like to ask you about some recommendations/hints to run this project on the iris/diabetes datasets that were included in the previous version of the project: https://github.com/mccorby/FederatedServer

is there any more specific tutorial?

hi, I am new with Android development, and the tutorial in the README is s bit simple.
I have been struggle with the code for some days. I am focusing on the server side and so far I have build the code using Android Studio (I am not sure if this is ok.) instead of IntelliJ Idea. AND I do not know what to do next (e.g. launch a server with what kind of plugin or how to test the server ).
Here I want to get some help. a more specific tutorial is very very appreciated.
THANKS!

MismatchedInputException: No content to map due to end-of-input

Hi, I'm one of the developers interested in Federated Learning, thus I've been trying to run your Photolabeller example.

While trying to run the server, I'm faced with an error that I cannot figure out the reason.

I succeed to run the Main.kt file by providing arguments to the function and it successfully saved the result.

Then, I tried to run the Federated Learning server by executing the JobQueueServer. The server was successfully started as shown in the screenshot.
Screen Shot 2020-10-24 at 7 02 25 AM

However, when I tried to check that the server is up and running in your local installation by hitting the suggested URL http://localhost:9997/service/federatedservice/available, I got the following error.
image

Full error message:

Oct 24, 2020 7:05:40 AM org.glassfish.jersey.internal.Errors logErrors
WARNING: The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 2
com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4134)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3988)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2909)
	at com.mccorby.photolabeller.server.core.datasource.FileDataSourceImpl.retrieveCurrentUpdatingRound(FileDataSourceImpl.kt:80)
	at com.mccorby.photolabeller.server.core.datasource.ServerRepositoryImpl.retrieveCurrentUpdatingRound(ServerRepositoryImpl.kt:29)
	at com.mccorby.photolabeller.server.web.RestService.<init>(RestService.java:38)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
	at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
	at org.glassfish.jersey.inject.hk2.RequestContext.findOrCreate(RequestContext.java:83)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:777)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:740)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:710)
	at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getInstance(AbstractHk2InjectionManager.java:184)
	at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getInstance(ImmediateHk2InjectionManager.java:54)
	at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:129)
	at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:284)
	at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:75)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:110)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:93)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:62)
	at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:269)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
	at org.eclipse.jetty.server.Server.handle(Server.java:497)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
	at java.lang.Thread.run(Thread.java:748)
MultiException stack 2 of 2
java.lang.IllegalStateException: Unable to perform operation: create on com.mccorby.photolabeller.server.web.RestService
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:393)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
	at org.glassfish.jersey.inject.hk2.RequestContext.findOrCreate(RequestContext.java:83)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:777)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:740)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:710)
	at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getInstance(AbstractHk2InjectionManager.java:184)
	at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getInstance(ImmediateHk2InjectionManager.java:54)
	at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:129)
	at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:284)
	at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:75)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:110)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:93)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:62)
	at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:269)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
	at org.eclipse.jetty.server.Server.handle(Server.java:497)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
	at java.lang.Thread.run(Thread.java:748)


8634 [qtp64830413-27] WARN org.eclipse.jetty.servlet.ServletHandler - 
javax.servlet.ServletException: A MultiException has 2 exceptions.  They are:
1. com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
2. java.lang.IllegalStateException: Unable to perform operation: create on com.mccorby.photolabeller.server.web.RestService

	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:432)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
	at org.eclipse.jetty.server.Server.handle(Server.java:497)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
	at java.lang.Thread.run(Thread.java:748)
Caused by: A MultiException has 2 exceptions.  They are:
1. com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
2. java.lang.IllegalStateException: Unable to perform operation: create on com.mccorby.photolabeller.server.web.RestService

	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:392)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
	at org.glassfish.jersey.inject.hk2.RequestContext.findOrCreate(RequestContext.java:83)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:777)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:740)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:710)
	at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getInstance(AbstractHk2InjectionManager.java:184)
	at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getInstance(ImmediateHk2InjectionManager.java:54)
	at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:129)
	at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:284)
	at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:75)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:110)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:93)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:62)
	at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:269)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
	... 18 more
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4134)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3988)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2909)
	at com.mccorby.photolabeller.server.core.datasource.FileDataSourceImpl.retrieveCurrentUpdatingRound(FileDataSourceImpl.kt:80)
	at com.mccorby.photolabeller.server.core.datasource.ServerRepositoryImpl.retrieveCurrentUpdatingRound(ServerRepositoryImpl.kt:29)
	at com.mccorby.photolabeller.server.web.RestService.<init>(RestService.java:38)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
	at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
	... 47 more
8637 [qtp64830413-27] WARN org.eclipse.jetty.server.HttpChannel - /service/federatedservice/available
javax.servlet.ServletException: A MultiException has 2 exceptions.  They are:
1. com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
2. java.lang.IllegalStateException: Unable to perform operation: create on com.mccorby.photolabeller.server.web.RestService

	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:432)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
	at org.eclipse.jetty.server.Server.handle(Server.java:497)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
	at java.lang.Thread.run(Thread.java:748)
Caused by: A MultiException has 2 exceptions.  They are:
1. com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
2. java.lang.IllegalStateException: Unable to perform operation: create on com.mccorby.photolabeller.server.web.RestService

	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:392)
	at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
	at org.glassfish.jersey.inject.hk2.RequestContext.findOrCreate(RequestContext.java:83)
	at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2126)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:777)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:740)
	at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:710)
	at org.glassfish.jersey.inject.hk2.AbstractHk2InjectionManager.getInstance(AbstractHk2InjectionManager.java:184)
	at org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.getInstance(ImmediateHk2InjectionManager.java:54)
	at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:129)
	at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:284)
	at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:75)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:110)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:113)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:93)
	at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:62)
	at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:269)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:268)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
	... 18 more
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
	at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4134)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3988)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2909)
	at com.mccorby.photolabeller.server.core.datasource.FileDataSourceImpl.retrieveCurrentUpdatingRound(FileDataSourceImpl.kt:80)
	at com.mccorby.photolabeller.server.core.datasource.ServerRepositoryImpl.retrieveCurrentUpdatingRound(ServerRepositoryImpl.kt:29)
	at com.mccorby.photolabeller.server.web.RestService.<init>(RestService.java:38)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
	at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
	at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
	... 47 more
8641 [qtp64830413-27] WARN org.eclipse.jetty.server.HttpChannel - Could not send response error 500: javax.servlet.ServletException: A MultiException has 2 exceptions.  They are:
1. com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
 at [Source: (File); line: 1, column: 0]
2. java.lang.IllegalStateException: Unable to perform operation: create on com.mccorby.photolabeller.server.web.RestService

Could you help me to handle this error?

Excution Guide

I interested in federated learning too.
So I download your code and then tried to excute both server and client programs of Photolabeller.

In server side, , even though the server(JobQueueServer) is executed,
but when I hit the url to check that the server is up and running, there is an error that cannot find "currentRound.json.'

And In client app side, the application on the device is installed successfully.
And I click the "training in device" button, but the app is forced shutdown with an error.

The error is below.================================================
06-22 10:53:26.061 16821-17063/com.mccorby.photolabeller I/System.out: org.deeplearning4j.nn.multilayer.MultiLayerNetwork@7867d03
06-22 10:53:34.740 16821-16821/com.mccorby.photolabeller I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
06-22 10:53:34.743 16821-16821/com.mccorby.photolabeller V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@52e8889
06-22 10:53:34.991 16821-16821/com.mccorby.photolabeller I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
06-22 10:53:34.996 16821-16821/com.mccorby.photolabeller I/AudioManagerEx: AudioManagerEx created
06-22 10:53:35.009 16821-16828/com.mccorby.photolabeller I/art: Do partial code cache collection, code=44KB, data=62KB
06-22 10:53:35.009 16821-16828/com.mccorby.photolabeller I/art: After code cache collection, code=43KB, data=62KB
06-22 10:53:35.010 16821-16828/com.mccorby.photolabeller I/art: Increasing code cache capacity to 256KB
06-22 10:53:35.017 16821-16821/com.mccorby.photolabeller V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@52e8889
06-22 10:53:35.017 16821-16821/com.mccorby.photolabeller V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@52e8889
06-22 10:53:35.026 16821-17287/com.mccorby.photolabeller I/System.out: Train started
06-22 10:53:35.053 16821-17287/com.mccorby.photolabeller I/System.out: []
06-22 10:53:35.063 16821-17287/com.mccorby.photolabeller W/o*.r*.Reflections: given scan urls are empty. set urls in the configuration
06-22 10:53:35.379 16821-17287/com.mccorby.photolabeller I/System.out: Epoch=====================0
06-22 10:53:35.382 16821-17287/com.mccorby.photolabeller I/System.out: next batch 16
06-22 10:53:35.382 16821-17287/com.mccorby.photolabeller I/System.out: Creating dataset for indexes 0 to 0
06-22 10:53:35.393 16821-16821/com.mccorby.photolabeller E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mccorby.photolabeller, PID: 16821
java.lang.IllegalArgumentException: Unable to merge empty dataset
at org.nd4j.linalg.dataset.DataSet.merge(DataSet.java:157)
at com.mccorby.photolabeller.trainer.ClientCifarLoader.createDataSet(ClientCifarLoader.kt:30)
at com.mccorby.photolabeller.trainer.ClientCifarDataSetIterator.next(ClientCifarDataSetIterator.kt:17)
at org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator.next(RecordReaderDataSetIterator.java:389)
at org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator.next(RecordReaderDataSetIterator.java:52)
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.fit(MultiLayerNetwork.java:982)
at com.mccorby.photolabeller.trainer.TrainerImpl.train(TrainerImpl.kt:87)
at com.mccorby.photolabeller.interactor.Train.run(Train.kt:15)
at com.mccorby.photolabeller.interactor.Train.run(Train.kt:8)
at com.mccorby.photolabeller.interactor.UseCase$execute$job$1.doResume(UseCase.kt:13)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:54)
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:161)
at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:25)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1383)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:256)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1123)
at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1961)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1909)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:128)

**Do I have to training image file in the specified directory?

So, could you tell me more sequential guide of excution this program? (both server & client)
And could you upload the additianal .json file?**

Initial model generation

On the client side, when running the application, I can see that the initial model used is the one located in assets folder. If we create the initial model on the server (PhotoLabellerServer/model/src/main/kotlin/com/mccorby/photolabeller/ml/Main.kt), and then we use the generated model in the app, the model misbehaves; The prediction for the images as well as the scores at each iteration when training the new model show a NaN values.

So how the initial model in the assets folder has been generated ?

Model Training

Hello,

When running the Main.kt, the zipped file "cifar_federated" is being generated containing the following:

  • coefficient.bin
  • configuration.json
    -updateState.bin

However i am getting the following error:

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)
Caused by: java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388)
at org.nd4j.linalg.util.ArrayUtil.buildInterleavedVector(ArrayUtil.java:1679)
at org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.shuffle(CpuNDArrayFactory.java:814)
at org.nd4j.linalg.factory.Nd4j.shuffle(Nd4j.java:452)
at org.nd4j.linalg.dataset.DataSet.shuffle(DataSet.java:619)
at org.datavec.image.loader.CifarLoader.convertDataSet(CifarLoader.java:380)
at org.datavec.image.loader.CifarLoader.next(CifarLoader.java:424)
at org.datavec.image.loader.CifarLoader.next(CifarLoader.java:392)
at org.deeplearning4j.datasets.iterator.impl.CifarDataSetIterator.next(CifarDataSetIterator.java:110)
at com.mccorby.photolabeller.ml.trainer.CifarTrainer.eval(CifarTrainer.kt:97)
at com.mccorby.photolabeller.ml.MainKt.main(Main.kt:39)
... 5 more

Would you advise in this regard please

Unmatched DL4J version between client and server

I observed that when the client sends weight updates back to server, I get the following exception. I figured out that the client used DL4J 1.0.0-beta3, while the server used 0.8.0, and there is an enum that doesn't exist in the older version.

How do you resolve this exception? We cannot downgrade the client version since 0.8.0 doesn't support ARM (I think - I tried to downgrade and it seems so). We cannot upgrade the server to 1.0.0-beta3 as well, since there are many library methods that are used in com.mccorby.photolabeller.ml.Main.kt are depreciated in newer version.

Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: No enum constant org.nd4j.linalg.api.buffer.DataBuffer.AllocationMode.LONG_SHAPE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.