Error NullPointer Neuroph doOneLearningIteration - java

I'm using Neuroph 2.9 framework to code ANN to predict housing prices. I want get every error every time run every epoch (to show the improve of error on chart) but this cause error.
// create multi layer perceptron
System.out.println("Creating neural network");
MultiLayerPerceptron neuralNet = new MultiLayerPerceptron(
TransferFunctionType.SIGMOID, inputsCount, hiddentsCount1,
outputsCount);
// set learning parameters
MomentumBackpropagation learningRule = new MomentumBackpropagation();
learningRule.setLearningRate(0.3);
learningRule.setMomentum(0.5);
learningRule.setNeuralNetwork(neuralNet);
learningRule.setTrainingSet(TrainSet);
learningRule.doOneLearningIteration(TrainSet);
I get this:
Exception in thread "main" java.lang.NullPointerException
at org.neuroph.nnet.learning.MomentumBackpropagation.updateNeuronWeights(MomentumBackpropagation.java:72)
at org.neuroph.nnet.learning.BackPropagation.calculateErrorAndUpdateOutputNeurons(BackPropagation.java:83)
at org.neuroph.nnet.learning.BackPropagation.updateNetworkWeights(BackPropagation.java:53)
at org.neuroph.core.learning.SupervisedLearning.learnPattern(SupervisedLearning.java:190)
at org.neuroph.core.learning.SupervisedLearning.doLearningEpoch(SupervisedLearning.java:165)
at org.neuroph.core.learning.IterativeLearning.doOneLearningIteration(IterativeLearning.java:245)
at com.thao.Main.main(Main.java:76)
The problem is when I use : learningRule.learn(TrainSet); it's ok, no error come out. The documentation so bad to differ functions to chose right function to run the right thing I want.

The thing I found is that doOneLearningIteration function didn't work because inside them. It's not initiated. Therefore, to run, we need to override or run 1 epoch and then doOneLearningIteration.
That's work for me.

Related

UnsopportedOperationException TODO when running R script with renjin in java

I'm new to R and Renjin, but I'm trying to run a legacy R script from a spring boot service and I'm getting this Unsupported exception. I've narrowed down the issue on the legacy script to a call made to svymean R function.
I've added details in here https://github.com/bedatadriven/renjin/issues/494
The design is generated with:
svrepdesign(data = svy_data, type = "JK1", weights = ~ weights, repweights = "weights[1-9]+")
What I've tried so far is:
Adding dependencies that could have been missing (matrix, base, stats), this didn't work and in some cases it only generated more problems
Commenting the parameters I'm passing in one by one, this didn't make any difference, the error still appears
I also tried with another similar function svytotal and I'm getting the same error
Could it be that it's just not supported to calculate the mean with replicated weighted? And if so, there is another way to calculate this and still use renjin? And if not, any other recommendation to use instead of renjin to run R legacy code?
The same script with the same parameters is running just fine from within RStudio.

JTwitter : getStatus()

I'm creating a desktop Twitter client in Java and I'm using JTwitter.
I tested a few lines of code with this library, which seems good, but I'm stuck at one point.
When running my app, Eclipse prints :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at winterwell.jtwitter.InternalUtils.asMap(InternalUtils.java:170)
at winterwell.jtwitter.Twitter.getStatus(Twitter.java:1646)
at Twittshader.main(Twittshader.java:34)
If you want to see the code (oauthClient and twitter objects are declared, I don't think the problem comes from these) :
oauthClient.authorizeDesktop();
String v = oauthClient.askUser("Please enter the verification PIN from Twitter");causes that.
oauthClient.setAuthorizationCode(v);
String[] accessToken = oauthClient.getAccessToken();
// Works through all the program but crashes at this point
System.out.println(twitter.getStatus("ShadeosIsaac"));
twitter.setStatus("Running some tests");
I really don't know why it is crashing. I'm pretty sure it is quite a simple thing, but I'm not sure what to do. Ideas ?
Can I ask: What version of the JTwitter jar do you have?
You can find this with: System.out.println(Twitter.version);

JavaFX - Media("File://derp") terminates with exception: MEDIA_INNACCESSIBLE

I'm trying to get a simple mp3 to run while my program runs, through this:
Media med = new Media("file://C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
MediaPlayer mPlayer = new MediaPlayer(med);
mPlayer.play();
But I'm running into problems. Running the program terminates with exception Exception in thread "main" MediaException: MEDIA_INACCESSIBLE : C, with reference to the first line of the code segment above, the one calling the Media() constructor.
I've had no previous experience with javafx or playing media in code, would anyone have any idea on why it would deem the file inaccessible? Am I doing anything simple incorrectly?
The file is, of course, fine. I can open it in a myriad different media players and it's fine.
This way it will work:
Media med = new Media("file:///C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
Note 3 slashes after file:.
Here is why: https://superuser.com/questions/352133/what-is-the-reason-that-file-urls-start-with-three-slashes-file-etc

Exception breakpoint occurred at EventDispatchThread.java

we are getting this error at the end of running application. I search in google buti don't know what cause this error and what this means. What to do and how to solve it?
i even don't know what raise this exception...
Exception breakpoint occurred at line 145 of EventDispatchThread.java.
java.lang.NullPointerException:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at oracle.jbo.uicli.jui.JUTableBinding$JUTableModel$2.run(JUTableBinding.java:1209)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Don't know what kind of searches you have performed on Google. I would suggest looking up each error (or rather each class where error occurs). Starting from the beginning as subsequent errors may be a due to error propagation. Two searches for EventDispatchThread and JUTableBinding.java may provide some insight at what went wrong.
http://www.docjar.org/docs/api/java/awt/EventDispatchThread.html
It seems that this class deals with AWT components ("takes events off the EventQueue and dispatches them to the appropriate AWT components")
For the JUTableBinding.java there are quite a few pages that say about NullPointerException
https://forums.oracle.com/forums/thread.jspa?threadID=515213
https://forums.oracle.com/forums/thread.jspa?threadID=2343921
https://kr.forums.oracle.com/forums/thread.jspa?threadID=503593
Some of them say that the problem may be with jdk version (seems 1.6 and above throw errors). I would assume that may be the case. Try to recompile using earlier versions of jdk and check whether error is still there. If it is not this then we will investigate further.
"I've looked into the code and found out that JUTableBinding.JUTableModel calls
mScrollUnit = control.getScrollableUnitIncrement(null,
SwingConstants.VERTICAL, 0);
(Line 947)
This was okay in Java 5, since JTable's getScrollableUnitIncrement just returned the row height."
"I changed the line to:
mScrollUnit = control.getScrollableUnitIncrement(
control.getVisibleRect(), SwingConstants.VERTICAL, 0);
and everything works fine on Java 6..."
Hope it helps.

Error message when querying the datastore

I am new to Java, Eclipse, Google App Engine and the Datastore and am writing my first app to teach myself some new technology both for work and for professional development purposes.
I have a Java app that successfully saves and retrieves data from a datastore that I have created based upon the key. I now want to be able to do more general queries based upon other information in my datastore for meta-code such as:
select key_column from my datastore where other_column = "data to be searched"
To achieve this, I have done some on-line reading and referenced the O'Reilly book Programming Google App Engine. I started with the sample code and it fails with the error message:
An error occured while attempting to contact the server.
Please check your network connect and try again
My code at this point is:
Query q = new Query("Force");
q.addFilter("ForceName", Query.FilterOperator.EQUAL, input);
PreparedQuery pq = datastore.prepare(q);
for (Entity forceresult : pq.asQueryResultIterable()); {
String newinput = (String) result.getProperty("ForceCode");
}
The error occurs on the last String netinput line.
The datastore code exists and is good - I have successfully written/read from it.
The documentation on the above sample code is lacking however to a newbie in this area, for instance: I am assuming that the Entity 'forceresult' only exists within the for loop and cannot be referenced from outside it - that is fine with me.
However, in the String newinput line, I have coded result.getProperty even though it seems to me that it should be forceresult.getProperty as this is what I want to refer to.
When I code that however, Eclipse tells me that it cannot resolve forceresult even though an Entity has been defined in the line above.
Is result a reserved word that I missed the significance of?
Is my code wrong in any other respect? Perhaps I am not understanding asQueryResultIterable properly yet?
How should I interpret the error message:
An error occured while attempting to contact the server.
Please check your network connect and try again
I hope someone can point me in the right direction either with a specific answer or advice on where to go next in my learning curve.
You have an error in your loop (a ; too much :)). Try this:
for (Entity forceresult : pq.asQueryResultIterable()) {
// ^ ; was here
String newinput = (String) result.getProperty("ForceCode");
}
Thus your loop was actually empty and the result.getProperty(...) got called outside, where forceresult isn't defined.

Categories