Neural networks tutorial: Fully Connected 10 [Java] - Saving and loading

Поделиться
HTML-код
  • Опубликовано: 20 дек 2024
  • Parser package + methods (in the text file): www.mediafire.c...
    Full /src folder: www.mediafire.c...
    I will start studying mechanical engineering in Aachen soon so I will not have that much time anymore. However, I could make smaller tutorials on smaller topics like the parser class, any algorithms etc. If you have an idea just ask me in the comment section. :)

Комментарии • 79

  • @bosa6632
    @bosa6632 5 лет назад

    you can use the first method if you put in the serialVersionUID in the class. This makes sure that every version of the class uses the same key. It's also not hard to do because when you implement Serializable to write down the code, eclipse recommends you to put in a key.

    • @finneggers6612
      @finneggers6612  5 лет назад

      The This good to know! Thank you! But still, changing variables etc will cause this method to not work properly, right?

  • @magicmaster4552
    @magicmaster4552 5 лет назад

    Thanks for your impressive lessons. But when I run it, here is a NULL PONTER EXCEPTION in indexOfHighestValue method. Could you help me with it, please?

    • @finneggers6612
      @finneggers6612  5 лет назад

      Magic Master show me your code then

    • @magicmaster4552
      @magicmaster4552 5 лет назад

      Thanks. I could run it. I think it was because of my PC. When I copied and pasted it in another file, it was okay. What a miracle! 😂 haha

    • @magicmaster4552
      @magicmaster4552 5 лет назад

      I was modifying your code so that I could get the result of only one image(The image is passed as an input). But the result is not satisfying :"( When I input the image which shows ZERO for three times, it says 8, 0, 7. Is there a bettery way ? I mean do I need to train more data ? Thank you a lot. Your tutorials help us, newbies to ML, a lot.

    • @finneggers6612
      @finneggers6612  5 лет назад

      Magic Master I am not sure what exactly you mean, could you send me your full network class?

    • @magicmaster4552
      @magicmaster4552 5 лет назад

      How can I send you?

  • @sebastian8193
    @sebastian8193 5 лет назад

    Hi Finn, ich habe als Einstieg ins Thema Neuronale Netze die Reihe angesehen und selbst mitprogrammiert. Nachdem ich fertig war habe ich jedoch nur ein Ergebnis con 60-70% erreicht und deshalb dein fertigen Ordner runtergeladen und verglichen. Ich habe dann alles verglichen und keinen Unterschied gemerkt. Dann habe ich den parser-Ordner und den mnist-Ordner (außer mnist.java) kopiert. Wenn ich die Dateien jetzt kompilieren will kommt immer etwas, wie "parser\Attribute.java:3:26: error: package parser.parsertools does not exist".
    Vorher kam das nicht. Hast du eine Idee, wodurch das kommt bzw. was ich dagegen machen kann?
    Wenn das geht könnte ich dir die Dateien auch zuschicken.

    • @finneggers6612
      @finneggers6612  5 лет назад

      Mhm. Ich vermute mal dass die Klasse ParserTools nicht existiert oder am falschen Ort ist. Schau mal bitte ob du irgendwo so eine Klasse findest. Wenn nicht dann kann ich dir die gerne schicken

  • @anizivzivadze5914
    @anizivzivadze5914 4 года назад

    I have been writing my senior thesis on this topic for college and this has been a tremendous help. Thank you. However, I have some difficulties training the network:
    Network network = new Network(784, 50, 10);
    trainData(network, createTrainSet(0,100), 1000, 100, 100, "Data/mnist.txt");
    Once it reaches 1000 epochs, the result is around 60% of accuracy(takes around 20 mins). If i just run for 10 seconds or so( like you did in the video) the accuracy is higher like 68% why is that? And what numbers should I enter to get like 98% or higher accuracy? I am okay with waiting for a day or so to train it as long as I get good results.
    I feel like I should boost the epochs but till what number? Please, help
    Thank you, Ani

    • @finneggers6612
      @finneggers6612  4 года назад

      Well your network is pretty small. Maybe try something like 784, 100, 80,50,10. If this does not work, you probably have some error somewhere.

    • @anizivzivadze5914
      @anizivzivadze5914 4 года назад

      @@finneggers6612 it got worse, like 10 % :(

    • @finneggers6612
      @finneggers6612  4 года назад

      @@anizivzivadze5914 10% is randomness on MNIST. So I guess there is a problem within the network itself.
      You should compare the code

    • @anizivzivadze5914
      @anizivzivadze5914 4 года назад

      @@finneggers6612 I am mortified to bother you this much, but i am literally using and loading your project that u uploaded and still dont go beyond 68%.
      Maybe, we should change the number of epochs, batch sizes, loops and network sizes? otherwise, I have no idea where the problem is.

    • @finneggers6612
      @finneggers6612  4 года назад

      @@anizivzivadze5914 Mhm okay that is odd... There can be multiple reasons for this but it should definetly go higher because the amount of images you train on is so small.
      Maybe you should try with my AI library that I use for mostly anything. You can use different activation functions here.
      github.com/Luecx/AILibrary/tree/master/src/neuralnetwork
      A model like that would be created like this:
      NetworkBuilder builder = new NetworkBuilder(1,28,28);
      builder.addLayer(new FlattenLayer()); //to make the 1x28x28 to 1x1x784
      builder.addLayer(new DenseLayer(100).setActivationFunction(new ReLu()));
      ...
      Network network = builder.buildNetwork();
      network.calculate() returns a list of tensors (basically the output data) but we only have one tensor in this case which one error function so you can call network.calculate(input)[0]

  • @grevel1376
    @grevel1376 5 лет назад

    Really good job making this series

  • @vladisoul9668
    @vladisoul9668 5 лет назад

    hi man amazing lessons . just one question ...how did you use your input in this program? where have you add the input (learn input and teach input)?...where have you input the folder of your data set

  • @redwulf85048
    @redwulf85048 7 лет назад +1

    These Tutorials are amazing! Do you know of any other resources I can look into to increase my knowledge on this subject?? Keep up the good work!!!

    • @finneggers6612
      @finneggers6612  7 лет назад +2

      Hey redwulf85048. Yes there are many resources but it totally depends on how you like to learn how this works.
      The first thing you should consider is learning a different network architecture. I highly recommend conv. neural networks or recurrent neural networks. Especially the second one can be used for so much. It is widely used in creating game bots, chat bots, sound bots etc.
      However conv. neural networks are able to create their own paintings and so on. So it is impressive what they can do.
      As a start you should watch some YT-Videos that explain the basic architecture. Usually the feedforward process is explained in detail but when it comes to the learning step, most videos simply refer to the backprop. algorithm without exactly explaining what each neuron is doing.
      Sometimes Wikipedia has the correct formulas but Wikipedia has way to much information given and it is a big mess finding what you want.
      One of the best ways of implementing and learning is to register in the StackExchange forum. It is a collection of around 200 forums. Some about maths, some about programming and some about AI, Deep Learning etc. Just ask your question there and someone will hopefully answer your question as long as your question is detailed and exact.
      I would love to keep my work up but my education is consuming a lot of time right now. I would love to implement my own recurrent neural network but haven't had the time yet. If I find some time I might show you guys how that works. However if you manage to implement a recurrent neural network feel free to present it :)
      Furthermore I thought about presenting different programs that I've written. Like my chessEngine (really poor tbh. but it works) or my 3DEngine, server based programs etc.

  • @captainsesman343
    @captainsesman343 6 лет назад

    Hi Finn, How is Studies going!... I am actually new into Neural Network, I have followed your tutorials and would love to apply the knowledge learned into detection system am trying to build ran into a brick and dont know if u can be of assistance.

    • @finneggers6612
      @finneggers6612  6 лет назад

      Captain Sesman sure, what are you trying to do?

    • @captainsesman343
      @captainsesman343 6 лет назад

      +Finn Eggers okay. I want to build an accident detection system that uses the speed, acceleration and noise as inputs which will return just one output. my Questions are very plenty was hoping if I can get your audience so I can elaborate more.

    • @finneggers6612
      @finneggers6612  6 лет назад

      Captain Sesman sure. How would you like to talk to me? Discord? Skype? Teamspeak? Just tell me your name and I will contact you ASAP

    • @captainsesman343
      @captainsesman343 6 лет назад

      I think Skype will be fine......captainsesman is my skype ID. I hope to hear from u ASAP

  • @v1das007
    @v1das007 5 лет назад

    Amazing tutorial that helps me a lot, but I feel that you drifted away a bit with the Serializable explanation. It doesn't work not because you updated java or that it has some hidden ids, but because it's not the same class anymore (you added new methods). Naturally, you cannot cast a wrong object. Great stuff, though, thanks a lot.

    • @finneggers6612
      @finneggers6612  5 лет назад

      v1das007 Serializing classes is a dangerous thing. It works as long as the class does not change. Assuming that you don’t want to change any code and not update java or anything like that, it might work.
      It’s an easy way to save a network.
      That’s why i have shown a different attempt with my own classes to write a txt file and read from that.
      If you have any questions. Feel free to ask:)

  • @yohguy4655
    @yohguy4655 7 лет назад

    Hey thanks for the tutorial, but is there anyway i can turn this from needing a target to just trying to get the highest score?

    • @finneggers6612
      @finneggers6612  7 лет назад

      yoh guy well you might need to redefine your error for that. I’ve seen a really nice explanation on the web but I can’t find it anymore. Try to redefine your cost function and it takes into the account the travelled distance. Then, apply geadient descent to minimise the error/maximise the travelled distance.
      But sadly I am not that sure about that. If you want I could ask a friend of mine. He is a Dr and is working with networks professionally

    • @yohguy4655
      @yohguy4655 7 лет назад

      That would be great, I am making one for my final project at school. I am trying to get it to learn how to play 2048 ,but I don't know how to teach it.

    • @finneggers6612
      @finneggers6612  7 лет назад

      I will try my best. I will see him probably on Thursday... However you can check out "Cross Validated". It's part of StackExchange and it focuses on things like machine learning. You can try to put your question there and hopefully someone will give you a good answer :)
      I can ask the question aswell if you prefer.

    • @finneggers6612
      @finneggers6612  7 лет назад

      stats.stackexchange.com/questions/323502/neural-network-to-play-2048
      I am busy right now so the text is not beautiful but it might do the job :)

    • @yohguy4655
      @yohguy4655 7 лет назад

      ok, thank you very much for everything, looking forward to the next series.

  • @benkelcher1304
    @benkelcher1304 7 лет назад

    How can I load my own png images to use with the trained network?

    • @finneggers6612
      @finneggers6612  7 лет назад

      Assuming that the dimensions have the correct size (28x28) you could use the following code:
      BufferedImage img = ImageIO.read(new File("res/7.png"));
      double[] in = new double[784];
      for(int i = 0; i < 28; i++) {
      for(int n = 0; n< 28; n++) {
      in[n * 28 + i] = (float)(new Color(img.getRGB(i,n)).getRed()) / 256f;
      }
      }
      What you need is a good image (28p x 28p) with black background and white forground. The width of the number should have the same width as the numbers in the mnist dataset have.
      Furthermore the image needs to be located in the res folder in your working directory. In this example I used an image called "7.png".

    • @benkelcher1304
      @benkelcher1304 7 лет назад

      Thanks, it seems to be working.

    • @nightfall2863
      @nightfall2863 7 лет назад

      you should make a video for this

    • @finneggers6612
      @finneggers6612  7 лет назад

      On how to load images? Or how the parser works?

  • @necromanhd7716
    @necromanhd7716 7 лет назад

    Could you make a tutorial about how to create a simple chat bot with a neural network?

    • @finneggers6612
      @finneggers6612  7 лет назад

      Depends on what kind of chat bot it should be? Do you have something in mind? Reading complex sentences is not possible with a simple feed forward neural network because of the variation of the input string length. Generally, I would say that a recurrent neural network is an optimal choice for language processing. I can tell you the basics about that but I think there exist a lot of good explanations on the web on that topic :)

    • @necromanhd7716
      @necromanhd7716 7 лет назад

      Can you ,if you have enough time, explain how to implement the basics of a recurrent neural network?

    • @finneggers6612
      @finneggers6612  7 лет назад

      Well yeah I could. Can you tell me what the bot is supposed to do?

    • @necromanhd7716
      @necromanhd7716 7 лет назад

      Nothing too complex, he should only be able to answer simple questions such as "how is your name" or "how are you."

    • @finneggers6612
      @finneggers6612  7 лет назад

      Well that already starts being complicated. Recurrent neural Networks are some of the most complex Networks out there. I can Show you the basics of them if you wish :)

  • @ThePrinceCanal
    @ThePrinceCanal 7 лет назад

    Hi, Can you make a same tutorial for Extension Neural Network?

    • @finneggers6612
      @finneggers6612  7 лет назад

      Ufff... I've never read myself into that topic. Is it big? Like is it a completly new architecture or how do they work?

    • @ThePrinceCanal
      @ThePrinceCanal 7 лет назад

      yes, it's new. you can find the learning algorithm here : pdfs.semanticscholar.org/4d6a/fbef9518546779ee9bbd3dcff024541ed2c3.pdf
      ps. also please add me on fb: Tutunaru Dan Marin

    • @ThePrinceCanal
      @ThePrinceCanal 7 лет назад

      it's not big, and it's almost like the Neural Network + Extension Theory, it is interesting.

  • @wanchodas
    @wanchodas 7 лет назад

    Hey man :) is ann applicable in binary classification?

    • @finneggers6612
      @finneggers6612  7 лет назад +1

      I've never tried it but I am 100% sure that they are because I've talked about that with a friend a week ago. So for example you could train your network like this:
      Give him n images from a trainset. The output if the image is from the trainset should be 1. If there is an input that does not come from the trainset the output should be 0.
      So there can be a "generator" that trains to generate images and gives it to the neural network. If the output of the network is 0.5, the network is not sure wether the data came from the trainset or from the generator.
      I gotta be honest and I am not that sure how it works exactly. It's probably really easy but I've never done that.
      But back to your question: Usually ANNs can be used in nearly and classification field.

  • @likeyou3317
    @likeyou3317 7 лет назад

    Too bad there was no "next video", gr8 series tho.

    • @finneggers6612
      @finneggers6612  7 лет назад

      Yeah... I actually prepared something but I am totally running out of time. I am studying mechanical enginnering and working as a programmer for the RWTH. I am working with neural nets but sadly I am not allowed to talk about the specific content :/.
      If anyone wants to present something or continue he can feel free to do so.
      Like, if you want to present a new architecture, an example or anything feel free to do so.
      I've made some nice simulations but again: I do not have the time to make a video out of it :/

    • @likeyou3317
      @likeyou3317 7 лет назад

      Well if accidently you will happen to have some time then know that there are folks who would watch it tho. I looked up the rwth thing and it appears to be university. It's weird that they don't want you to talk about brand new things from neurals u work on, like a corp that want to be better than the competition. :D

  • @necromanhd7716
    @necromanhd7716 7 лет назад

    one great Tutorial more