Пікірлер
@lukke7148
@lukke7148 5 күн бұрын
Interesting! I am also making my own chess engine at the moment and am shocked to see what is similar and different in our approaches. I believe I have some stuff that might make your model better. First off, the 13th channel in your input data might really confuse the model considering it only contains data about where pieces can move TO, not WHICH piece can do that and from where. Instead, you should have the 13th channel completely filled with 1s or 0s based on what side it is playing (since right now it has to also predict if it is playing black or white). Not directly telling the model which side it is playing IS THE REASON why it was previously prone to making many illegal moves since it could not train well (I did the same mistake of having 12 channels also). Sure, it might still want to make illegal moves sometimes, but instead of doing a legal check for each input board position, you can check if the predicted move is legal, and if it is not, choose the next best-predicted move. I saw you made a comment about a 14th dimension, and even though I can buy your reasoning, I do not believe this is the most effective strategy considering the model will have to make many extra predictions along the way when many FROM squares are filled and many TO squares are filled. Also during training, opening moves are irrelevant considering many of them are interchangeable. Your model will be punished by choosing one opening over another, which is not fair. I was shocked to see that even though my model never trained on opening moves, it could still predict near-perfect theory when getting better at the game as a whole. It also reached better precision after training without opening moves because it was not unfairly punished. Another big tip is using batch normalization after each convolutional layer. It might make the training process much slower, but each part of the training gets much more efficient, resulting in a much higher precision after the same amount of epochs. For example, my model took about 7000 games of training to reach 2% accuracy without batch normalization and after implementation, it was reached already after 500 games.
@_NickTech
@_NickTech 5 күн бұрын
Hey! I love your tips, especially the one about openings-it's truly shocking! You're right-legal check is indeed algorithmically inefficient in my implementation. And telling the model which side it's playing sounds so logical! However, I still think it should have an extra channel indicating which pieces it can move (this should be tested in an experiment). Though I agree, telling WHERE it can move them is really ambiguous. By the way, accuracy doesn't seem like a reasonable metric here (I understand it's easier to compute). I would suggest Top-3 or Top-5 Accuracy, since sometimes there can be up to even 10 decent moves
@lukke7148
@lukke7148 5 күн бұрын
@@_NickTech Yes, you could absolutely be right about the extra channel, but maybe one could create some system to embed more information inside it instead of using only 1s and 0s? For example some kind of embedding to make it possible for the model to understand exactly which piece can move to some specific square. It would be really interesting to see how these kinds of inputs change the outcome of the model, especially if it is a solution you come up with by yourself! And yes, you are completely right about the accuracy, it is a super good tip and something I will implement now! Looking forward to the reinforcement 😉
@david-oruna
@david-oruna 15 күн бұрын
I'm currently also making a chess engine but with js, and now that I've seen that is possible to use neural networks I think I might change to python haha
@fyve2806
@fyve2806 27 күн бұрын
For I now, I still don't how to get all the codes from GitHub to the code writing software (maybe I'll use the default one on Windows).
@Vedranation
@Vedranation Ай бұрын
What you can do to improve it is follow DeepMind's approach. You trained your supervised model and its pretty decent, It could probably beat any 900 elo player. What you wanna do now is take the model and chuck it into reinforcement learning to roughen up the endgame edges. I believe early game is strong because early game is consistent in training data, but no 2 end games are the same so it's lacking in training material there. I feel reinforcement learning here would greatly improve it.
@Vedranation
@Vedranation Ай бұрын
thats crazyyyy!
@rollercoasterhd
@rollercoasterhd Ай бұрын
Great Video! But may I suggest, that you could use a fragment (pixel) shader to increase the rendering speed of the fractal?
@Carlo-zs5lw
@Carlo-zs5lw Ай бұрын
Very interesting video man, detailed explanation👍 do you code in processing as well?
@_NickTech
@_NickTech Ай бұрын
Thanks for the kind words! 😊 I haven’t coded in Processing before
@_NickTech
@_NickTech Ай бұрын
I had to render the video with some loss in quality and sound due to my editing tool crashing. I hope it's still bearable. Sorry about that! It will be better in the next videos 👨‍💻 CODE: github.com/Skripkon/MandelbrotSet
@_NickTech
@_NickTech Ай бұрын
code: github.com/Skripkon/MandelbrotSet First part: kzbin.info/www/bejne/gYG3i6aJhp13macsi=8M89zovnQ9cgbMOy Second part: kzbin.info/www/bejne/l4Szc2N8qdtgaKMsi=A-d-AmbGbqLcViwK
@below8
@below8 Ай бұрын
Super video! Amazing. Waiting for the next video of zooming areas logic!
@absolute-narwhal
@absolute-narwhal Ай бұрын
this is super underrated bro, well done
@_NickTech
@_NickTech Ай бұрын
Thanks! I appreciate it!
@juliansantos1900
@juliansantos1900 Ай бұрын
the issue of zooming in is being very close to the binary floating point limitation
@_NickTech
@_NickTech Ай бұрын
You got it right! Though no one forbids using arbitrary-precision arithmetic
@user-bw2vq9lp2v
@user-bw2vq9lp2v Ай бұрын
Very informative and entertaining, i enjoyed it very much!
@_NickTech
@_NickTech Ай бұрын
Glad to hear it! Thank you for watching!
@_NickTech
@_NickTech Ай бұрын
second part (zooming): kzbin.info/www/bejne/l4Szc2N8qdtgaKM
@Neo-137
@Neo-137 Ай бұрын
i didnt get the action space part as ı understand your action space is the number of unique moves in the dataset, and ı think it leads to the model cant choose any other move that is not in the data set. The move index in the action space depends on the data as well. you can use alpha zeros action representation 56 queen moves (8 direction 7 max length) 8 knight moves and 9 underpromotion(3 pieces 3 direction) for 8*8 board in the and u have 73*8*8 matrix after flattening 4672 length action space.
@_NickTech
@_NickTech Ай бұрын
Hey, you got it correctly! However, when the dataset is quite large, the probability that there won't be a needed move is really low (unless you start playing 'exotic' chess). You can plot a graph of the number of unique moves versus the number of parsed games. The convergence to the asymptote is good. But sure, you can create an action space that includes all possible moves
@user-nh3fn9mq1g
@user-nh3fn9mq1g Ай бұрын
Бля, ахуенный монтаж. Шикарное видео!! Продолжай!!
@MrCustomabstract
@MrCustomabstract Ай бұрын
Comment for algo
@minh3485
@minh3485 Ай бұрын
Great video, I would love to see more simulation C++ contents in the future.
@Tocharianne
@Tocharianne Ай бұрын
Nice, concise video. Thank you for not having unnecessary background music.
@_NickTech
@_NickTech Ай бұрын
Thank you for watching.
@teamfoxear
@teamfoxear Ай бұрын
weak model I train with 10k games but still cant play decent moves.
@wyndmill
@wyndmill Ай бұрын
javascript is a totally normal language that makes perfect sense
@techworld3255
@techworld3255 Ай бұрын
We have Fireship at home Fireship at home:
@bjni
@bjni Ай бұрын
yeah im good I will stick to golang
@AmirparsaDD
@AmirparsaDD Ай бұрын
this video format makes me remember how humans invented [fire] and decided to [ship] it to prodution
@ahmoin
@ahmoin Ай бұрын
0:10 you're supposed to use the strict equality operator according to google typescript style guide "Always use triple equals (===) and not equals (!==). The double equality operators cause error prone type coercions that are hard to understand and slower to implement for JavaScript Virtual Machines."
@_NickTech
@_NickTech Ай бұрын
Then the result will obviously be false (due to the type check), and the example will be obscure. By the way, it's a matter of coding style, though === is preferred by the majority (and for good reason)
@ahmoin
@ahmoin Ай бұрын
@@_NickTech yes i said === is preferred by googles typescript style guide
@SeresHotes25
@SeresHotes25 Ай бұрын
I like your content! I don't understand why there're so many hate comments :(
@_NickTech
@_NickTech Ай бұрын
I appreciate your kind words, thank you!
@hamzagohar2048
@hamzagohar2048 Ай бұрын
I like the video but i think you should work on your accent a bit its too thick
@_NickTech
@_NickTech Ай бұрын
Thank you for your support! I'm actively working on improving my speech. Hopefully, it'll be easier to follow me in the future
@bee_irl
@bee_irl Ай бұрын
i didn't mind the accent, i could understand everything and it's not annoying to me:) you know what _is_ annoying? javascr
@nothappyz
@nothappyz Ай бұрын
​@@_NickTech please don't change your accent just for these people. Accents are normal they're just mad you don't have an american accent like it's the only one there
@jdudbdjxb7687
@jdudbdjxb7687 Ай бұрын
I mean I see what you mean but it's not hard to understand Even as an American, I can make out everything
@zoki5388
@zoki5388 Ай бұрын
as someone who is beginner with python but I would like to play around with object detection in video game, which libraries you would recommend me to look at?
@_NickTech
@_NickTech Ай бұрын
Hey, OpenCV, TensorFlow, PyTorch, YOLO, Detectron2 are good options. OpenCV is known for its simplicity and ease of use, so I would recommend to start with it
@_NickTech
@_NickTech Ай бұрын
What do you like (or hate) the most about JavaScript? BTW, this video didn't mean to discourage you from learning it 😅
@alwinsebastian7499
@alwinsebastian7499 Ай бұрын
i love javascript because it put food on the table. and i dont really hate it.may be a little, for being weird.
@YihyunML
@YihyunML Ай бұрын
In future save the tensor data to a file and read it in chunks for training so you can train on a larger dataset without memory issues
@_NickTech
@_NickTech Ай бұрын
Sure! Thank you for advising
@robertomartins8085
@robertomartins8085 2 ай бұрын
That is an awesome video! I have two main questions: 1. Why did you shuffle the dataset, since the games itself might be considered as a series of moves through time (though one game has nothing to do with the other). 2. Why did you choose CNN, I understand that you could frame the input as an image, but it would be fun to see the difference to a regular MLP. Also I've played against your bot and it seems to be very solid (congrats) it also made the same blunder as it did when playing against you (giving away the rook with a check) - since the bot is actually learning from moves (and there are 10^120) and most games have early and midgames but not so many late games, it may seem that the use of a evaluation calculation might be needed (hence Reinforcement Learning)
@_NickTech
@_NickTech Ай бұрын
Hey, thanks for your comment! 😊 The dataset includes sequential moves where each move depends on previous states. Shuffling helps prevent the model from learning sequential dependencies that do not generalize well to new games. Otherwise, it might only learn specific openings, for example. Shuffling ensures that the model sees a variety of positions in each batch, which is beneficial for learning. Using an MLP for this task is interesting, but I doubt it would catch any patterns as effectively as a CNN. CNNs seem logical to me for this kind of data. And yes, you are right: evaluation calculation is not only needed but essential! For the CNN model, there is no difference between a blunder and a brilliant move. Only evaluation can solve that problem. Regarding endgames, there is one obvious issue: there are so many possible positions. Openings are relatively standard: develop pieces, control the center, and castle your king. Middlegames are trickier, but endgames are extraordinarily varied! There are no clear patterns in them
@ponmuthu..4796
@ponmuthu..4796 2 ай бұрын
try using re-enforcement learning
@_NickTech
@_NickTech 2 ай бұрын
it's on my TODO list, though I've been told that convergence will be poor. We'll see
@ponmuthu..4796
@ponmuthu..4796 Ай бұрын
@@_NickTech why pytorch one is considerably better even with same architecture can you explain? How much ram ,vram does it used,also have you use multiprocessing
@_NickTech
@_NickTech Ай бұрын
You mean in comparison with the TF model from my other video? If so, the architecture is different: I changed the input (there were 12 channels; I added one more). If you apply that change to the TF model, then you will get a similar result. Though PyTorch has a more efficient memory management system (for example, it uses a dynamic computation graph rather than a static one like in TF), which allowed me to train a model using more data. I didn't use multiprocessing, though you can easily add it to the data loading by specifying *num_workers*: data_loader = DataLoader(dataset, batch_size, num_workers=4) About RAM: 16-30 GB were in use, depending on how many samples you keep in your dataset.
@ponmuthu..4796
@ponmuthu..4796 Ай бұрын
@@_NickTech may I create a interface for that(I can use the frontend from by University project with improvements)
@_NickTech
@_NickTech Ай бұрын
@@ponmuthu..4796 My friend has already created an interface for it, which I'll cover in the next video: setday.github.io/chess-engine-online/ his github repo: github.com/setday/chess-engine-online But you can create it as well for the sake of practicing :)
@ponmuthu..4796
@ponmuthu..4796 2 ай бұрын
really decent bot, it is better than my pure nural network bot,my bot gives evaluation value to a position as output than negamax
@_NickTech
@_NickTech 2 ай бұрын
Thanks for watching!
@tarlkudrick1174
@tarlkudrick1174 2 ай бұрын
I was hoping you'd show how to build a neural net from scratch. That is, instead of using a pre-made library, start with nothing beyond numpy and pandas, and go from there. My problem with python is that other people have already done most of the work, so all a person really needs to do is download someone else's pre-made set of solutions and learn how to use that solution's commands. I guess what I'd really like to see is how to build a neural net in Assembly or something 🙂
@_NickTech
@_NickTech 2 ай бұрын
Hey, "TensorFlow" is in the title and on the thumbnail 😁. That's a great idea, thank you! I want to do it, though not in assembly, I'm afraid. But in C/C++ with the usage of GSL for linear algebra, I guess
@nmxnunezz8214
@nmxnunezz8214 2 ай бұрын
i have been trying to do this exact same thing for the last month. I took the exact same approach without that 13th dimension and never got good results, its impressive how such a little thing can have such a huge impact. Thanks a lot, great video
@_NickTech
@_NickTech 2 ай бұрын
You can also add a 14th dimension for even better results. The 13th channel shows where you can move pieces, but it doesn't show from which squares you can move them. I've already tried it; the results will be better, though blunders are inevitable, of course. Here is how you can modify the board_to_matrix function to include the 14th dimension (auxiliary_func.py, from line 22): for move in legal_moves: to_square = move.to_square from_square = move.from_square row_to, col_to = divmod(to_square, 8) row_from, col_from = divmod(from_square, 8) matrix[12, row_to, col_to] = 1 matrix[13, row_from, col_from] = 1 And thanks a lot for your comment! I'm glad you liked the video!
@nmxnunezz8214
@nmxnunezz8214 Ай бұрын
​@@_NickTech I implemented your idea and something wasnt working so i decided to use your exact same architecture and it worked perfectly fine. Could you please explain how you decided to take that exact architecture? thanks! This was my architecture before: class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.a1 = nn.Conv2d(5, 16, kernel_size=3, padding=1) self.a2 = nn.Conv2d(16, 16, kernel_size=3, padding=1) self.a3 = nn.Conv2d(16, 32, kernel_size=3, stride=2) self.b1 = nn.Conv2d(32, 32, kernel_size=3, padding=1) self.b2 = nn.Conv2d(32, 32, kernel_size=3, padding=1) self.b3 = nn.Conv2d(32, 64, kernel_size=3, stride=2) self.c1 = nn.Conv2d(64, 64, kernel_size=2, padding=1) self.c2 = nn.Conv2d(64, 64, kernel_size=2, padding=1) self.c3 = nn.Conv2d(64, 128, kernel_size=2, stride=2) self.d1 = nn.Conv2d(128, 128, kernel_size=1) self.d2 = nn.Conv2d(128, 128, kernel_size=1) self.d3 = nn.Conv2d(128, 128, kernel_size=1) self.last = nn.Linear(128, 1) def forward(self, x): x = F.relu(self.a1(x)) x = F.relu(self.a2(x)) x = F.relu(self.a3(x)) # 4x4 x = F.relu(self.b1(x)) x = F.relu(self.b2(x)) x = F.relu(self.b3(x)) # 2x2 x = F.relu(self.c1(x)) x = F.relu(self.c2(x)) x = F.relu(self.c3(x)) # 1x128 x = F.relu(self.d1(x)) x = F.relu(self.d2(x)) x = F.relu(self.d3(x)) x = x.view(-1, 128) x = self.last(x) # value output return F.tanh(x)
@_NickTech
@_NickTech Ай бұрын
@nmxnunezz8214 hey, I see two major issues: 1. Why nn.Linear(128, 1) at the end? Are you solving a regression task? And why scale the output to the range [-1, 1] with F.tanh(x)? This should be a classification task, not regression. The last layer should be nn.Linear(128, number_of_unique_moves). Then apply softmax to get probabilities. 2. Do you only have 5 channels? Why so few? I inferred this from nn.Conv2d(5, ... ).
@user-yu5ym4ud9y
@user-yu5ym4ud9y 2 ай бұрын
Есть какое-то логическое обоснование тому, почему при одинаковых слоях и параметрах модели так по-разному отрабатывают? Или вся разница как раз в 13м канале? Спасибо за видео
@_NickTech
@_NickTech 2 ай бұрын
Yes! You're absolutely right! The 13th channel did all the work here. (I don't remember the precise numbers, but when I trained the TF model with the 13th channel, the convergence and performance were about the same). It's actually logical because this 13th channel indicates some rules of chess, and the correlation with the target is obviously high. I should've mentioned this in the video 😬 Thank you for your comment!
@user-yu5ym4ud9y
@user-yu5ym4ud9y 2 ай бұрын
@@_NickTech Thanks for the response. Good luck with your future videos!
@_NickTech
@_NickTech 2 ай бұрын
Play against this engine here: setday.github.io/chess-engine-online/
@Alanhallow
@Alanhallow 2 ай бұрын
Why python, why not any other faster languages?
@_NickTech
@_NickTech 2 ай бұрын
In ML and DL, people usually use Python, unless it's for HFT. Speed was not my primary concern in this project, so coding with Python was much faster and easier. That's it. Typically, drafts are written in Python first and only rewritten in C/C++ if necessary
@Andrew_J123
@Andrew_J123 2 ай бұрын
nice vid!
@trevoreguitar
@trevoreguitar 2 ай бұрын
Hey! ML Engineer here- this was interesting to watch! I have a couple comments for what I partially understand as it relates to chess engines. The biggest issue really isn't within the size of your training dataset. The classification method of your model to determine next moves is a fun application but it suffers (as you saw in the video) from a lack of rules & general understanding of the game. It's incapable of looking ahead, and is attempting? to play a move within some similar pattern in the board representation. This fails due to 1) The absurd size and amount of discrepancies within purely "positional" chess, where "similar to" doesn't really produce good results. The reason chess engines have an evaluation bar "scoring" the moves, is because it is the most effective way to let them "think", as it pertains to the exact position on the board, given a future sequence of moves. An idea (although again, out of my wheelhouse) would be to take every legal move from each position, use some scoring means (there's a really impressive video on youtube about someone creating an engine in C in under 1024 tokens which can conceptualize this task far better than I can), and then performing a regression with the score of the move (you can still use a neural network), using the same board+move pattern. You can even extend this to include all legal moves. If you want it to play "more" like a human than you can probably bias the score within the later segments of the game towards whoever won. You can also batch your training processes & fix the hidden layer sizing to allow more data in. In the final decision of "next-move" (using all legal moves to avoid the error you ran into + the score on each) you could then use your model to adjust the evaluation (of a prebuilt scoring engine), or attempt to drop the initial scoring engine in favor of JUST the neural network's regression-output. I can't say the pure NN method will produce good results though, as chess is a game that requires looking ahead as it evaluates the "current" position.
@_NickTech
@_NickTech 2 ай бұрын
Hey, thank you for such a detailed comment! You are totally right - without knowledge of the game and predicting only the next move, any pure NN method is doomed. I love the idea of solving a regression task with scoring. But to get a score for each move, would you need to use Stockfish or another engine? If so, it seems strange to me: using one engine to build another, esp. which will perform much worse
@trevoreguitar
@trevoreguitar 2 ай бұрын
@@_NickTech I mean it all depends on how you frame it, to me the "scoring" methodology is just as important to the process of Machine Learning as is applying the model type. You can also build any of these "scoring engines" from scratch, with the basic ones using pure addition/subtraction and a recursive loop w/ a depth limit. In the instance of a classification model, it's not scoring but you can create a category of the legal moves being "good", "decent", "bad" to better apply the concept of choose-from-all-legal-moves. A pure NN approach is interesting but yeah it will always be awful considering that it's just sort being fed a garbage-in garbage-out without any means to score each individual move given the board state. If, however, you wanted to do a no-think-ahead engine you could consider the following - generally, a move is "losing" closer to the end of the game. So using the move counter of the game, and that knowledge, you could apply a more-negative score to moves made nearing the end of the game on the side that loses, and inverse for the side that wins. Then just flat apply some metric to the earlier moves to balance the distribution. And then in the instance of a draw, score the moves by the game length to achieve the draw, with a more even-random distribution. There are a million things to try, but ultimately there's a reason that every top engine is "score + neural net" and no flat-neural net classifier has done well (even the 2016 alpha zero taught itself how to score)
@_NickTech
@_NickTech 2 ай бұрын
​@@trevoreguitar I see what you mean. Thank you for your insights. By the way, an interesting fact: Stockfish neither use scoring nor neural nets when there are <= 7 pieces on the board. Stockfish solves the game perfectly using endgame databases
@hariharan-wx9oq
@hariharan-wx9oq 2 ай бұрын
really cool project!! Thanks man!!
@_NickTech
@_NickTech 2 ай бұрын
Glad you like it! Thanks for kind words!
@boukefmohamed3191
@boukefmohamed3191 2 ай бұрын
Most KZbinrs use the minimax algorithm, but using neural networks for chess is truly special. You are a legend! I would love to see a video on how we can contribute to an open-source engine like Stockfish.
@_NickTech
@_NickTech 2 ай бұрын
Stockfish can already easily defeat any human, as far as I know 😄 And then there's AlphaZero as well... 😱 Still, it's a nice idea, thank you!
@ozymandias8523
@ozymandias8523 2 ай бұрын
Im gonna come back after I learn python, this is like alchemy to me rn
@_NickTech
@_NickTech 2 ай бұрын
Best of luck to you in learning Python! When you come back, feel free to ask any questions!
@aaravasawa
@aaravasawa 2 ай бұрын
Make this video go viral
@aaravasawa
@aaravasawa 2 ай бұрын
Good one mate
@_NickTech
@_NickTech 2 ай бұрын
Thanks! I appreciate your kind comment!
@septspb
@septspb 2 ай бұрын
Yeahhhh, new video finally!👍 Thnx a lot!
@_NickTech
@_NickTech 2 ай бұрын
Thanks for watching! More content is on the way, so stay tuned! 😊
@domergamer2257
@domergamer2257 2 ай бұрын
Hi Nick! I have no idea about this, but I have a doubt... Is your training model restricted by your RAM memory? Can't it be done in many stages? Is it possible to Plug in two computers in series and get the computation quicker? BTW sweet video! Watched till the end. Keep it coming 🎉❤
@_NickTech
@_NickTech 2 ай бұрын
Hey! Thanks for your support, I appreciate it! ❤ About RAM - yeah, it's a common problem with neural networks, esp. CNNs, because of the size of tensors X and Y. But you can manage it in stages. Just remember, the last layer's size has to match the vocabulary (total number of legal moves in the dataset). This layer must stay fixed-you can't change the NN structure after training. So, start by creating a big array of unique targets (as long as it fits in memory). Once you've fixed the size and set up mappings like int_to_move & move_to_int, you can split X into segments (X_1, X_2, ..., X_n) and train the model iteratively with each segment. It should work fine, but it'll take hours, days, weeks, months... Using multiple computers: Yep, it's possible (called "distributed and parallel training"). TensorFlow and Keras support this approach, though I haven't tried it myself yet (
@domergamer2257
@domergamer2257 2 ай бұрын
@@_NickTech Cool! Thanks for the explanation. I would love to see this project turned into a series...
@_NickTech
@_NickTech 2 ай бұрын
second part (huge improvement): kzbin.info/www/bejne/Y4ing5SIis-Fg8k
@deejae_music
@deejae_music 5 ай бұрын
Hey does this work with sqlite database my flask app has?
@_NickTech
@_NickTech 5 ай бұрын
Hey, yes, sure! Here is some discussion on this topic: community.render.com/t/database-on-github-sqlite3/536 Note that if you need to persist files, such as SQLite databases, you’ll require a persistent storage solution. A "Render disk" would be the best option for a SQLite file; however, disks are only available on paid plans. Otherwise, you will lose your data after each deployment
@shankertarunaditya3474
@shankertarunaditya3474 5 ай бұрын
i am deploying a Django project what I have to enter in the start command
@_NickTech
@_NickTech 5 ай бұрын
it depends on your particular project, but sth like CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] should work