├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .project ├── 9781484253830.jpg ├── Contributing.md ├── LICENSE.txt ├── README.md ├── coens-ai-notes ├── .gitignore ├── Classifying-Iris.qmd ├── Finding-Data.qmd ├── Magic-behind-NNetwork.qmd ├── Problem-with-perceptron.qmd ├── The-learning-Perceptron.qmd ├── Types-NN.qmd ├── Untitled.qmd ├── _metadata.yml ├── _output │ └── Coen-s-AI-Notes-and-Links.pdf ├── _quarto.yml ├── agents.qmd ├── ai.overview.qmd ├── attach │ ├── 2021-AI-General.034.png │ ├── 2021-AI-General.038.png │ ├── 2021-AI-General.039.png │ ├── 2021-AI-General.040.png │ ├── 2021-AI-General.041.png │ ├── 2021-AI-General.044.png │ ├── Mark_I_perceptron.jpeg │ ├── Perceptron01.png │ ├── TypicalNeuron.png │ ├── ai.laundry.art.maciejewska.jpg │ ├── perceptron02.png │ └── perceptron03.png ├── buildBook.sh ├── convert_to_quarto.sh ├── education.ai.qmd ├── experiments │ ├── MCP-hands-on.qmd │ └── references.qmd ├── finetune.qmd ├── fix_frontmatter.sh ├── fix_image_paths.sh ├── genai.qmd ├── index.AI.qmd ├── index.qmd ├── journalism.ai.qmd ├── mcp.qmd ├── neural-network.qmd ├── nocodelowcode.qmd ├── perceptron.qmd ├── rag.qmd ├── references.ai.act.qmd ├── references.ai.qmd ├── references.bib ├── references.genai.qmd ├── train-finetune-rag.qmd └── train.qmd ├── errata.md ├── findings.md ├── img ├── 9781484253830.jpg ├── GT.Classifying-dots-line.png ├── GT.Fed.Neuron.png ├── GT.NeuralNetwork-detail.png ├── GT.NeuralNetwork.png ├── GT.Sigmoid.png ├── GT.git.load.png ├── GT.git.png ├── GT.lepiter.WorkshopAI.png ├── GT.lepiter.newDatabase.png └── GT.lepiter.png ├── index.qmd ├── lepiter.properties ├── lepiter ├── 1y2i7qlpbbxp9ltrg5kz7vx9v.lepiter ├── 31omg2wjvq7rubvpw2qswc3az.lepiter ├── 3lszqrc4rkn0fuuhnon2do41x.lepiter ├── 464egypn7sxbxxwhl5zlmwr2q.lepiter ├── 464egyppxvk7lk5b7a1zf9l7a.lepiter ├── 464egypsplgdeko8towogisqh.lepiter ├── 464egyqgi3lvu80cvx6we4qcg.lepiter ├── 464egyqjhgitq54s20oquakka.lepiter ├── 464egys65f9h2yduztfhgvbhy.lepiter ├── 464egysyt3si0kfd2yddat9ug.lepiter ├── 464egytlc6cpo1cm8ovl6gwda.lepiter ├── 464egyuhpf8zolyefjn7fe0uy.lepiter ├── 464egyv8mnjucjplumnx2oxwd.lepiter ├── 464egyviq7k6udnrx29wp7xdp.lepiter ├── 4xmeatwt8xnm54eb78ammcnj4.lepiter ├── 62kynqubeaj4pm1uvbv29tt4g.lepiter ├── 7bpus83qqylpr048gygdgp30o.lepiter ├── 84cgbo2quaxskmawpvs1qiwg.lepiter ├── 8o4mlwh0i3du859pjwwihkqxd.lepiter ├── 8zwglc8od5fk964ds4ax2ic67.lepiter ├── 8zwglc91tqkp76dx1d1dkxo49.lepiter ├── 93mdx44icqxle8f3r3mxd3h75.lepiter ├── 93mdx45oivf9ismwkvj2vu01d.lepiter ├── 93mdx45smbboazo7azjbbcagh.lepiter ├── 99c4u7yyn5ife84wfumhsadkn.lepiter ├── a4zoczyl3nigeu1txxwijpl28.lepiter ├── acj8ydkpqnqve6uaxjilp4rb2.lepiter ├── acubx5upl8on575dr6dv84vlj.lepiter ├── acubx5vdxkbi0y7e8u0iww1mq.lepiter ├── attachments │ ├── 25ngvq19h53k4jqhaa5z4og3r │ │ ├── AI-Bergel-1-neuron.png │ │ └── lepiter_attachment.properties │ ├── 3lszqra6jy6fswevlyq0nbwwp │ │ ├── lepiter_attachment.properties │ │ └── screenshot-appetizer.png │ ├── 506kjcde5gn8pi87kzqm6e1a9 │ │ ├── AI-Bergel-2-perceptron 1.png │ │ └── lepiter_attachment.properties │ ├── 93mdx42tkirmyu6xep5pninz4 │ │ ├── 2021-AI-General.051.png │ │ └── lepiter_attachment.properties │ ├── 93mdx43cuyk9ozqsnka2rswnb │ │ ├── 2021-AI-General.049.png │ │ └── lepiter_attachment.properties │ ├── 93mdx45vgrq9ult7mc0ug29re │ │ ├── 2021-AI-General.052.png │ │ └── lepiter_attachment.properties │ ├── 93mdx46vvditkr1u9395xa7an │ │ ├── 2021-AI-General.050.png │ │ └── lepiter_attachment.properties │ ├── 93mdx47z0l0xhikpfp5isfj3n │ │ ├── NeuralNetworks.Mobile-apps.png │ │ └── lepiter_attachment.properties │ ├── a2xz7edye9ovbir79lq915yby │ │ ├── TypicalNeuron.png │ │ └── lepiter_attachment.properties │ ├── a2xz7efdiumd2tb2rell119o8 │ │ ├── Perceptron01.png │ │ └── lepiter_attachment.properties │ ├── acubx5qhgc7mewm9oe9ipmju5 │ │ ├── 2021-AI-General.039.png │ │ └── lepiter_attachment.properties │ ├── acubx5res3wwqqsoqpln3973l │ │ ├── 2021-AI-General.040.png │ │ └── lepiter_attachment.properties │ ├── acubx5tw8s9pg69gxywngcd0d │ │ ├── 2021-AI-General.034.png │ │ └── lepiter_attachment.properties │ ├── acubx5u98dal5skto751e2ub7 │ │ ├── 2021-AI-General.041.png │ │ └── lepiter_attachment.properties │ ├── acubx5uloavw5osr26p7x3b60 │ │ ├── 2021-AI-General.038.png │ │ └── lepiter_attachment.properties │ ├── acubx5v6o9ka5u5phbhlcqnae │ │ ├── 2021-AI-General.035.png │ │ └── lepiter_attachment.properties │ └── cfq22ybf8bqck0thc6dzv2szj │ │ ├── 2021-AI-General.044.png │ │ └── lepiter_attachment.properties ├── bc8fiyxsivd5rh9622nrwcul4.lepiter ├── bn9w9ymvm7i1wqqhdjo50f9ul.lepiter ├── cgms9ex95d3nbntrbuof4al68.lepiter ├── cgms9f07o5p1qer3db8059wrs.lepiter ├── cgms9f0qyo511oiab1zd4wyns.lepiter ├── cgms9f2fc3o193m0mu3uzdolk.lepiter ├── cgms9f2hssv3mhmptnsd9rmug.lepiter ├── e0icqxudho0wf1957csq88yhs.lepiter ├── e187oyisp2ouz1ythumr3mx7s.lepiter ├── ek8coyhdegg5vge8pyevbbba1.lepiter └── lepiter.properties ├── markdown ├── chatWithChepetto01.md ├── chatWithChepetto02.md ├── chatWithChepetto03.md ├── infoAboutWorkshop.md └── mentimeter.md ├── scripts ├── 02-chapter2.txt ├── 03-chapter3.txt ├── 05-Learning.txt ├── 06-Data.txt ├── 07-MatrixLibrary.txt ├── 08-MatrixNN.txt ├── 10-GeneticAlgorithm.txt ├── 11-GAExamples.txt ├── 12-TravelingSalesmanProblem.txt ├── 13-Robot.txt ├── 14-Zoomorphic.txt ├── 15-ZoomorphicSimulation.txt ├── 16-Neuroevolution.txt ├── 17-NEAT.txt └── 18-MarioGame.txt ├── slides ├── 2021-AI-General.001.png ├── 2021-AI-General.002.png ├── 2021-AI-General.003.png ├── 2021-AI-General.004.png ├── 2021-AI-General.005.png ├── 2021-AI-General.006.png ├── 2021-AI-General.007.png ├── 2021-AI-General.008.png ├── 2021-AI-General.009.png ├── 2021-AI-General.010.png ├── 2021-AI-General.011.png ├── 2021-AI-General.012.png ├── 2021-AI-General.013.png ├── 2021-AI-General.014.png ├── 2021-AI-General.015.png ├── 2021-AI-General.016.png ├── 2021-AI-General.017.png ├── 2021-AI-General.018.png ├── 2021-AI-General.019.png ├── 2021-AI-General.020.png ├── 2021-AI-General.021.png ├── 2021-AI-General.022.png ├── 2021-AI-General.023.png ├── 2021-AI-General.024.png ├── 2021-AI-General.025.png ├── 2021-AI-General.026.png ├── 2021-AI-General.027.png ├── 2021-AI-General.028.png ├── 2021-AI-General.029.png ├── 2021-AI-General.030.png ├── 2021-AI-General.031.png ├── 2021-AI-General.032.png ├── 2021-AI-General.033.png ├── 2021-AI-General.034.png ├── 2021-AI-General.035.png ├── 2021-AI-General.036.png ├── 2021-AI-General.037.png ├── 2021-AI-General.038.png ├── 2021-AI-General.039.png ├── 2021-AI-General.040.png ├── 2021-AI-General.041.png ├── 2021-AI-General.042.png ├── 2021-AI-General.043.png ├── 2021-AI-General.044.png ├── 2021-AI-General.045.png ├── 2021-AI-General.046.png ├── 2021-AI-General.047.png ├── 2021-AI-General.048.png ├── 2021-AI-General.049.png ├── 2021-AI-General.050.png ├── 2021-AI-General.051.png ├── 2021-AI-General.052.png ├── 2021-AI-General.053.png ├── 2021-AI-General.054.png ├── 2021-AI-General.055.png ├── 2021-AI-General.056.png ├── 2021-AI-General.057.png ├── 2021-AI-General.058.png ├── 2021-AI-General.059.png ├── 2021-AI-General.060.png ├── 2021-AI-General.061.png ├── 2021-AI-General.062.png ├── 2021-AI-General.063.png ├── 2021-AI-General.064.png ├── 2021-AI-General.065.png ├── 2021-AI-General.066.png ├── 2021-AI-General.067.png ├── 2021-AI-General.068.png ├── 2021-AI-General.069.png ├── 2021-AI-General.070.png ├── 2021-AI-General.071.png ├── 2021-AI-General.072.png ├── 2021-AI-General.073.png ├── 2021-AI-General.074.png ├── 2021-AI-General.075.png ├── 2021-AI-General.076.png ├── 2021-AI-General.077.png ├── 2021-AI-General.078.png ├── 2021-AI-General.079.png ├── 2021-AI-General.080.png ├── 2021-AI-General.081.png ├── 2021-AI-General.082.png ├── 2021-AI-General.083.png ├── 2021-AI-General.084.png ├── 2021-AI-General.085.png ├── 2021-AI-General.086.png ├── 2021-AI-General.087.png ├── 2021-AI-General.088.png ├── 2021-AI-General.089.png ├── 2021-AI-General.090.png ├── 2021-AI-General.091.png ├── 2021-AI-General.092.png ├── 2021-AI-General.093.png ├── 2021-AI-General.094.png ├── 2021-AI-General.095.png ├── 2021-AI-General.096.png ├── 2021-AI-General.097.png ├── 2021-AI-General.098.png ├── 2021-AI-General.099.png ├── 2021-AI-General.100.png └── NeuralNetworks.Mobile-apps.png └── src ├── .properties ├── BaselineOfAgileArtificialIntelligence ├── BaselineOfAgileArtificialIntelligence.class.st └── package.st ├── Creature ├── CConnection.class.st ├── CCreature.class.st ├── CMuscle.class.st ├── CMuscleGenerator.class.st ├── CNode.class.st ├── CPlatform.class.st ├── CVisualElement.class.st ├── CWorld.class.st └── package.st ├── GeneticAlgorithm-Core ├── GAAbstractCrossoverOperation.class.st ├── GAAbstractMutationOperation.class.st ├── GAConstrainedCrossoverOperation.class.st ├── GACrossoverOperation.class.st ├── GAEngine.class.st ├── GAIndividual.class.st ├── GALog.class.st ├── GAMutationOperation.class.st ├── GAObject.class.st ├── GAOperation.class.st ├── GAOrderedCrossoverOperation.class.st ├── GASelection.class.st ├── GASwapMutationOperation.class.st ├── GATournamentSelection.class.st └── package.st ├── GeneticAlgorithm-Tests ├── GACrossoverOperationTest.class.st ├── GAEngineTest.class.st ├── GAIndividualTest.class.st ├── GAMutationOperationTest.class.st ├── GAOrderedCrossoverOperationTest.class.st └── package.st ├── Matrix ├── MMatrix.class.st ├── MMatrixTest.class.st └── package.st ├── MiniMario ├── MNAIMario.class.st ├── MNAbstractCharacter.class.st ├── MNMario.class.st ├── MNMonster.class.st ├── MNWorld.class.st └── package.st ├── NEAT ├── NEAT.class.st ├── NEAbstractMutationOperation.class.st ├── NEAbstractNonStructuralMutationOperation.class.st ├── NEAbstractStructuralMutationOperation.class.st ├── NEAddConnectionMutationOperation.class.st ├── NEAddNodeMutationOperation.class.st ├── NEConnection.class.st ├── NEConnectionWeightMutationOperation.class.st ├── NECrossoverOperation.class.st ├── NEIndividual.class.st ├── NELog.class.st ├── NENode.class.st ├── NESpeciation.class.st ├── NESpecies.class.st └── package.st ├── NeuralNetwork-GToolkit ├── NNetwork.extension.st ├── SlideSamples.class.st ├── SlidesForScripts02chapter2txt.class.st ├── SlidesForScripts03chapter3txt.class.st ├── SlidesForScripts05Learningtxt.class.st ├── SlidesForScripts06Datatxt.class.st ├── SlidesForScripts07MatrixLibrarytxt.class.st ├── SlidesForScripts08MatrixNNtxt.class.st ├── SlidesForScripts10GeneticAlgorithmtxt.class.st ├── SlidesForScripts11GAExamplestxt.class.st ├── SlidesForScripts12TravelingSalesmanProblemtxt.class.st ├── SlidesForScripts13Robottxt.class.st ├── SlidesForScripts14Zoomorphictxt.class.st ├── SlidesForScripts15ZoomorphicSimulationtxt.class.st ├── SlidesForScripts16Neuroevolutiontxt.class.st ├── SlidesForScripts17NEATtxt.class.st ├── SlidesForScripts18MarioGametxt.class.st ├── WASlidesFinal.class.st ├── WASlidesGeneralIntroNew.class.st ├── WASlidesGeneticAlgo.class.st ├── WASlidesNeuralNetwork.class.st ├── WASlidesNeuroEvolution.class.st ├── WorkshopAI.class.st ├── WorkshopAILearningGT.class.st ├── WorkshopAINeuronGT.class.st ├── WorkshopAIPerceptronGT.class.st ├── WsHelper.class.st └── package.st ├── NeuralNetwork-Matrix ├── NMLayer.class.st ├── NMNetwork.class.st └── package.st ├── NeuralNetwork ├── ActivationFunction.class.st ├── FiredNeuronShot.class.st ├── InputPseudoLayer.class.st ├── NNetwork.class.st ├── NNetworkTest.class.st ├── Neuron.class.st ├── NeuronLayer.class.st ├── NeuronLayerTest.class.st ├── NeuronTest.class.st ├── Normalization.class.st ├── NormalizationTest.class.st ├── Perceptron.class.st ├── PerceptronTest.class.st ├── SigmoidAF.class.st ├── StepAF.class.st └── package.st ├── NeuralTutorial ├── NeuralNetworkTutorial.class.st ├── NeuralNetworkTutorialTest.class.st └── package.st └── Robot ├── GARobot.class.st ├── GARobotMap.class.st └── package.st /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lepiter/*.bak 2 | **/.DS_Store 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | { 2 | 'srcDirectory' : 'src' 3 | } -------------------------------------------------------------------------------- /9781484253830.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/9781484253830.jpg -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Apress Source Code 2 | 3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. 4 | 5 | ## How to Contribute 6 | 7 | 1. Make sure you have a GitHub account. 8 | 2. Fork the repository for the relevant book. 9 | 3. Create a new branch on which to make your change, e.g. 10 | `git checkout -b my_code_contribution` 11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. 12 | 5. Submit a pull request. 13 | 14 | Thank you for your contribution! -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Freeware License, some rights reserved 2 | 3 | Copyright (c) 2020 Alexandre Bergel 4 | 5 | Permission is hereby granted, free of charge, to anyone obtaining a copy 6 | of this software and associated documentation files (the "Software"), 7 | to work with the Software within the limits of freeware distribution and fair use. 8 | This includes the rights to use, copy, and modify the Software for personal use. 9 | Users are also allowed and encouraged to submit corrections and modifications 10 | to the Software for the benefit of other users. 11 | 12 | It is not allowed to reuse, modify, or redistribute the Software for 13 | commercial use in any way, or for a user’s educational materials such as books 14 | or blog articles without prior permission from the copyright holder. 15 | 16 | The above copyright notice and this permission notice need to be included 17 | in all copies or substantial portions of the software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | SOFTWARE. 26 | 27 | 28 | -------------------------------------------------------------------------------- /coens-ai-notes/.gitignore: -------------------------------------------------------------------------------- 1 | /.quarto/ 2 | -------------------------------------------------------------------------------- /coens-ai-notes/Classifying-Iris.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical Example: Classifying Iris Flowers" 3 | --- 4 | 5 | ## A Real-World Machine Learning Challenge 6 | 7 | The Iris flower classification problem is a classic example in machine learning. It involves predicting the species of an Iris flower based on measurements of its physical characteristics. This problem perfectly illustrates how neural networks can solve real-world classification tasks. 8 | 9 | ![Different types of Iris flowers](attach/2021-AI-General.044.png) 10 | 11 | ## The Dataset 12 | 13 | The Iris dataset includes measurements of three different Iris species: 14 | - Iris Setosa 15 | - Iris Versicolor 16 | - Iris Virginica 17 | 18 | For each flower, we have four measurements: 19 | 1. Sepal length 20 | 2. Sepal width 21 | 3. Petal length 22 | 4. Petal width 23 | 24 | Building a network that can do this is really outside of the scope of these notes, 25 | but a lot of info can be found on the internet on `Iris Classification`. 26 | 27 | ## Key Learning Points 28 | 29 | 1. Neural networks can handle multi-class classification 30 | 2. Real-world data often needs preprocessing 31 | 3. We can measure success with accuracy metrics 32 | 4. The same principles apply to many similar problems 33 | 34 | This practical example demonstrates how neural networks can solve real classification problems. In the next section, we'll explore the mathematics behind how these networks learn. 35 | -------------------------------------------------------------------------------- /coens-ai-notes/Finding-Data.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Finding and Preparing Data" 3 | --- 4 | 5 | ## The Importance of Data 6 | 7 | Data is the foundation of most machine learning projects. 8 | The quality and quantity of your data often matter more than the sophistication of your model. 9 | 10 | 11 | 12 | ## Popular Data Sources 13 | 14 | - [Kaggle](https://www.kaggle.com/datasets) 15 | - Competitions and datasets 16 | - Active community 17 | - Detailed documentation 18 | 19 | - [Eindhoven open data](https://data.eindhoven.nl/pages/home/) 20 | - lots of data about Eindhoven 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /coens-ai-notes/Magic-behind-NNetwork.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "The Mathematics Behind Neural Networks" 3 | --- 4 | 5 | ## Understanding the Magic 6 | 7 | While neural networks might seem magical, they're built on solid mathematical foundations. 8 | Let's demystify (a bit of) how they actually work under the hood. 9 | 10 | ## The Building Blocks 11 | 12 | ### 1. Neurons and Weights 13 | 14 | To be formally correct we should say `artificial neuron` to distinguish them from 15 | `biological neurons` like we have in our brain. A neuron normally has inputs: $1$, or $2$, or $\cdots$ 16 | 17 | 18 | 19 | Each neuron performs two key operations: 20 | 1. Weighted sum of inputs. 21 | 2. Activation function: $a = f(z)$ 22 | 23 | 24 | ### 2. Activation Functions 25 | 26 | 27 | Common activation functions include: 28 | 29 | 1. Sigmoid: $f(x) = \frac{1}{1 + e^{-x}}$ 30 | - Outputs between 0 and 1 31 | - Useful for probability predictions 32 | 33 | 2. ReLU (Rectified Linear Unit): $f(x) = \max(0, x)$ 34 | - Simple and efficient 35 | - Helps prevent vanishing gradients 36 | 37 | 3. Tanh: $f(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}$ 38 | - Outputs between -1 and 1 39 | - Often better than sigmoid for hidden layers 40 | 41 | ## The Learning Process 42 | 43 | ### 1. Forward Propagation 44 | 45 | Information flows through the network. 46 | 47 | 48 | ### 2. Loss Calculation 49 | 50 | Measure the network's Error and Backpropagation 51 | 52 | - What is the output? 53 | - What would be my desired output? 54 | 55 | The smaller the difference between the output I got and the output I desired, the better the output of my model is. 56 | This difference is calculated with a so-called Loss function. 57 | Backpropagation is an algorithm that helps make that difference small. 58 | When backpropagation is performed we call that Training the AI model. 59 | 60 | 61 | -------------------------------------------------------------------------------- /coens-ai-notes/Problem-with-perceptron.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Understanding Perceptron Limitations" 3 | --- 4 | 5 | ## The XOR Problem: A Classic Challenge 6 | 7 | While Perceptrons are powerful tools for many classification tasks, they face a fundamental limitation: they can only solve linearly separable problems. The classic example of this limitation is the XOR (exclusive OR) function. 8 | 9 | ### What is XOR? 10 | 11 | The XOR function outputs 1 only when exactly one of its inputs is 1: 12 | - Input (0,0) → Output: 0 13 | - Input (0,1) → Output: 1 14 | - Input (1,0) → Output: 1 15 | - Input (1,1) → Output: 0 16 | 17 | ![Visual representation of XOR problem](attach/2021-AI-General.034.png) 18 | 19 | ### Why Can't a Single Perceptron Solve XOR? 20 | 21 | A Perceptron creates a single straight line (or hyperplane in higher dimensions) to separate its outputs. However, the XOR problem requires two separate lines to correctly classify all points. 22 | 23 | ![Attempted linear separation of XOR](attach/2021-AI-General.038.png) 24 | 25 | As you can see, no single straight line can separate the points where output should be 1 (blue) from points where output should be 0 (red). 26 | 27 | ## The Solution: Multiple Layers 28 | 29 | To solve the XOR problem, we need to combine multiple Perceptrons in layers. This is our first glimpse at why we need neural networks! 30 | 31 | ![Multi-layer solution](attach/2021-AI-General.039.png) 32 | 33 | By using multiple Perceptrons, we can: 34 | 1. First create separate regions with individual Perceptrons 35 | 2. Then combine these regions to form more complex decision boundaries 36 | 37 | ![Complete neural network solution](attach/2021-AI-General.040.png) 38 | 39 | ## Key Takeaways 40 | 41 | 1. Single Perceptrons can only solve linearly separable problems 42 | 2. Many real-world problems (like XOR) are not linearly separable 43 | 3. Combining Perceptrons into networks overcomes this limitation 44 | 4. This limitation led to the development of multi-layer neural networks 45 | 46 | In the next section, we'll explore how to build and train these more powerful multi-layer networks. 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /coens-ai-notes/The-learning-Perceptron.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "The Learning Perceptron" 3 | --- 4 | 5 | One of the most fascinating aspects of Perceptrons is their ability to 6 | learn from examples. Instead of manually setting weights and bias, 7 | we can train a Perceptron to discover the optimal parameters 8 | through a process called supervised learning. 9 | 10 | ## The Learning Algorithm 11 | 12 | The learning process follows these key steps: 13 | 14 | 1. Start with random weights and bias 15 | 2. Present a training example 16 | 3. Compare the Perceptron's output with the desired output 17 | 4. Adjust the weights and bias based on the error 18 | 5. Repeat with more examples until performance is satisfactory 19 | 20 | ### Mathematical Foundation 21 | 22 | The weight update rule is elegantly simple: 23 | 24 | ``` 25 | new_weight := current_weight + learning_rate * error * input 26 | ``` 27 | 28 | Where: 29 | 30 | - `learning_rate` is a small number (like 0.1) that controls how big each adjustment is 31 | - `error` is the difference between desired and actual output (1 or -1) 32 | - `input` is the input value for that weight 33 | 34 | 35 | ### Training Process 36 | 37 | To train the Perceptron, we have to have `labeled data` (ie. input data combined with the desired output for those values) 38 | 39 | So for training AND gate behavior we have to list all combinations of 2 bits that are possible as input, and also the desired output value: 40 | ``` 41 | | Input | Desired Output | 42 | |--------|----------------| 43 | | (0, 0) | 0 | 44 | | (0, 1) | 0 | 45 | | (1, 0) | 0 | 46 | | (1, 1) | 1 | 47 | ``` 48 | 49 | and training (1 epoc) means calling the train function with each of these examples: 50 | 51 | ``` 52 | foreach dataItem in trainingData do: 53 | inputs := dataItem[0] 54 | desiredOutput := dataItem[1] 55 | learningPerceptron train(inputs, desiredOutput) 56 | ``` 57 | 58 | ## Visualizing the Learning Process 59 | 60 | As the Perceptron learns, its decision boundary gradually moves to the correct position. You can monitor this progress by: 61 | 62 | 1. Tracking the error rate over time 63 | 2. Visualizing the decision boundary's movement 64 | 3. Testing the Perceptron with new examples 65 | 66 | ## Practical Considerations 67 | 68 | For successful learning: 69 | - Ensure your training data is representative 70 | - Consider using multiple training epochs (complete passes through the data) 71 | - Monitor for convergence (when the weights stabilize) 72 | - Be aware that not all problems are linearly separable 73 | 74 | In the next chapter, we'll explore the limitations of what a single Perceptron can learn, which will lead us naturally to the need for more complex neural networks. 75 | -------------------------------------------------------------------------------- /coens-ai-notes/Types-NN.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Exploring Neural Network Architectures" 3 | --- 4 | 5 | ## The Rich Landscape of Neural Networks 6 | 7 | Neural networks come in many shapes and sizes, each designed to excel at specific types of tasks. Let's explore some of the most important architectures and their applications. 8 | 9 | ## Feedforward Neural Networks (FNN) 10 | 11 | The classic architecture: Information flows in one direction: 12 | 13 | - Input layer → Hidden layer(s) → Output layer 14 | - Perfect for classification and regression tasks 15 | - Examples: Our Iris classifier, handwriting recognition 16 | 17 | ## Convolutional Neural Networks (CNN) 18 | 19 | Inspired by the human visual cortex: 20 | 21 | - Specialized for processing grid-like data (images, video) 22 | - Uses convolution operations to detect patterns 23 | - Excellent at feature extraction 24 | - Applications: Image recognition, computer vision, medical imaging 25 | 26 | ## Recurrent Neural Networks (RNN) 27 | 28 | Networks with memory: 29 | 30 | - Can process sequences of data 31 | - Information cycles through the network 32 | - Great for time-series data and natural language 33 | - Applications: Language translation, speech recognition, stock prediction 34 | 35 | ## Long Short-Term Memory (LSTM) 36 | 37 | A sophisticated type of RNN: 38 | 39 | - Better at remembering long-term dependencies 40 | - Controls information flow with gates 41 | - Solves the vanishing gradient problem 42 | - Applications: Text generation, music composition 43 | 44 | ## Autoencoders 45 | 46 | Self-learning networks: 47 | 48 | - Learn to compress and reconstruct data 49 | - Useful for dimensionality reduction 50 | - Can detect anomalies 51 | - Applications: Data compression, noise reduction, feature learning 52 | 53 | ## Generative Adversarial Networks (GAN) 54 | 55 | Two networks competing with each other: 56 | 57 | - Generator creates fake data 58 | - Discriminator tries to spot fakes 59 | - Through competition, both improve 60 | - Applications: Creating realistic images, style transfer, data augmentation 61 | 62 | ## Choosing the Right Architecture 63 | 64 | The choice of architecture depends on: 65 | 66 | 1. Type of data (images, text, time-series) 67 | 2. Task requirements (classification, generation, prediction) 68 | 3. Available computational resources 69 | 4. Need for real-time processing 70 | 71 | ## Future Directions 72 | 73 | Neural network architectures continue to evolve: 74 | 75 | - Hybrid architectures combining multiple types 76 | - More efficient training methods 77 | - Better handling of uncertainty 78 | - Integration with other AI techniques 79 | 80 | In the next section, we'll dive deeper into training these networks effectively. 81 | -------------------------------------------------------------------------------- /coens-ai-notes/Untitled.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Untitled" 3 | --- 4 | 5 | -------------------------------------------------------------------------------- /coens-ai-notes/_metadata.yml: -------------------------------------------------------------------------------- 1 | execute: 2 | echo: false 3 | warning: false 4 | 5 | format: 6 | html: 7 | theme: cosmo 8 | code-fold: true 9 | pdf: 10 | papersize: letter 11 | toc: true 12 | number-sections: true 13 | colorlinks: true 14 | fig-cap-location: bottom 15 | tbl-cap-location: top -------------------------------------------------------------------------------- /coens-ai-notes/_output/Coen-s-AI-Notes-and-Links.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/_output/Coen-s-AI-Notes-and-Links.pdf -------------------------------------------------------------------------------- /coens-ai-notes/_quarto.yml: -------------------------------------------------------------------------------- 1 | project: 2 | type: book 3 | output-dir: _output 4 | 5 | book: 6 | title: "Coen's AI Notes and Links" 7 | author: "diverse" 8 | date: last-modified 9 | chapters: 10 | - index.qmd 11 | - ai.overview.qmd 12 | - part: "GenAI" 13 | chapters: 14 | - genai.qmd 15 | - education.ai.qmd 16 | - references.genai.qmd 17 | - nocodelowcode.qmd 18 | - part: "AI Act Europe" 19 | chapters: 20 | - references.ai.act.qmd 21 | - part: "Train, Fine Tune, RAG" 22 | chapters: 23 | - train-finetune-rag.qmd 24 | - rag.qmd 25 | - finetune.qmd 26 | - train.qmd 27 | - part: "Data" 28 | chapters: 29 | - finding-data.qmd 30 | - part: "Related subjects" 31 | chapters: 32 | - agents.qmd 33 | - mcp.qmd 34 | - journalism.ai.qmd 35 | - part: "Neuron & Network" 36 | chapters: 37 | - perceptron.qmd 38 | - the-learning-perceptron.qmd 39 | - problem-with-perceptron.qmd 40 | - neural-network.qmd 41 | - classifying-iris.qmd 42 | - magic-behind-nnetwork.qmd 43 | - types-nn.qmd 44 | - references.ai.qmd 45 | - part: "Experiments" 46 | chapters: 47 | - experiments/references.qmd 48 | - experiments/MCP-hands-on.qmd 49 | 50 | format: 51 | pdf: 52 | documentclass: book 53 | toc: true 54 | number-sections: true 55 | colorlinks: true 56 | fig-pos: "H" 57 | include-in-header: 58 | text: | 59 | \usepackage{float} 60 | \usepackage{graphicx} 61 | \DeclareGraphicsExtensions{.pdf,.png,.jpg} 62 | \graphicspath{{./}{./attach/}} 63 | 64 | metadata-files: 65 | - _metadata.yml 66 | -------------------------------------------------------------------------------- /coens-ai-notes/agents.qmd: -------------------------------------------------------------------------------- 1 | # Agents 2 | 3 | ## Agent Development Kit 4 | 5 | - [https://google.github.io/adk-docs/https://google.github.io/adk-docs/](https://google.github.io/adk-docs/) 6 | 7 | ## Open Agent Platform 8 | 9 | - [docs.oap.langchain.com](https://docs.oap.langchain.com/) 10 | -------------------------------------------------------------------------------- /coens-ai-notes/ai.overview.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "AI Overview" 3 | --- 4 | 5 | ## AI, Machine Learning, Deep Learning, Generative AI 6 | 7 | The video "AI, Machine Learning, Deep Learning and Generative AI Explained" provides an excellent 10-minute overview: 8 | 9 | [AI, Machine Learning, Deep Learning and Generative AI Explained](https://www.youtube.com/watch?v=qYNweeDHiyU) 10 | 11 | 12 | -------------------------------------------------------------------------------- /coens-ai-notes/attach/2021-AI-General.034.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/2021-AI-General.034.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/2021-AI-General.038.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/2021-AI-General.038.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/2021-AI-General.039.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/2021-AI-General.039.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/2021-AI-General.040.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/2021-AI-General.040.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/2021-AI-General.041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/2021-AI-General.041.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/2021-AI-General.044.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/2021-AI-General.044.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/Mark_I_perceptron.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/Mark_I_perceptron.jpeg -------------------------------------------------------------------------------- /coens-ai-notes/attach/Perceptron01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/Perceptron01.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/TypicalNeuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/TypicalNeuron.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/ai.laundry.art.maciejewska.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/ai.laundry.art.maciejewska.jpg -------------------------------------------------------------------------------- /coens-ai-notes/attach/perceptron02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/perceptron02.png -------------------------------------------------------------------------------- /coens-ai-notes/attach/perceptron03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/attach/perceptron03.png -------------------------------------------------------------------------------- /coens-ai-notes/buildBook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Print colorful messages 4 | GREEN='\033[0;32m' 5 | RED='\033[0;31m' 6 | NC='\033[0m' # No Color 7 | 8 | echo "${GREEN}Starting book build process...${NC}" 9 | 10 | # Check if quarto is installed 11 | if ! command -v quarto &>/dev/null; then 12 | echo "${RED}Error: Quarto is not installed. Please install it first.${NC}" 13 | echo "Visit: https://quarto.org/docs/get-started/" 14 | exit 1 15 | fi 16 | 17 | # Ensure we're in the right directory 18 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 19 | cd "$SCRIPT_DIR" 20 | 21 | echo "${GREEN}Building book with Quarto...${NC}" 22 | 23 | # Run Quarto to build the PDF 24 | quarto render --to pdf 25 | 26 | # Check if the build was successful 27 | if [ $? -eq 0 ]; then 28 | echo "${GREEN}Book build completed successfully!${NC}" 29 | echo "Output directory: _output" 30 | else 31 | echo "${RED}Error: Book build failed. Check the error messages above.${NC}" 32 | exit 1 33 | fi 34 | 35 | open _output/Coen-s-AI-Notes-and-Links.pdf 36 | -------------------------------------------------------------------------------- /coens-ai-notes/convert_to_quarto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Convert all markdown files to qmd 4 | for file in *.md; do 5 | if [ "$file" != "README.md" ]; then 6 | # Create the new filename 7 | new_file="${file%.md}.qmd" 8 | # Convert spaces to hyphens in the filename 9 | new_file=$(echo "$new_file" | tr ' ' '-') 10 | # Copy the content 11 | cp "$file" "$new_file" 12 | echo "Converted $file to $new_file" 13 | fi 14 | done 15 | 16 | # Create references.bib if it doesn't exist 17 | touch references.bib -------------------------------------------------------------------------------- /coens-ai-notes/education.ai.qmd: -------------------------------------------------------------------------------- 1 | # AI versus education 2 | 3 | ## Media & Opinions 4 | 5 | - [bron.fontys.nl/nieuw-fraudebeleid-met-focus-op-preventie](https://bron.fontys.nl/nieuw-fraudebeleid-met-focus-op-preventie/) 6 | - [How AI is changing education](https://www.youtube.com/watch?v=OaEk-ZYzh80) 7 | - [column-mark-de-graaf-ga-ict-studeren](https://www.hbo-i.nl/nieuws/column-mark-de-graaf-ga-ict-studeren/) 8 | - [bron.fontys: een-eigen-ai-tool-voor-fontys](https://bron.fontys.nl/een-eigen-ai-tool-voor-fontys/) 9 | 10 | ## Tools, Best Practices & lesson material 11 | 12 | - [How to cite ChatGPT? Use AI Archive](https://medium.com/@kcao0228/how-to-cite-chatgpt-use-a-i-archives-bc254cb006d1) 13 | - [aiarchives.org](https://aiarchives.org/) 14 | - [You did it together with AI? Make a statement!](https://mmmlabel.tech/) 15 | - [hbo-i-outcomes-example-generator chatbot](https://chatgpt.com/g/g-FZWlHuaZh-hbo-i-outcomes-example-generator) 16 | - [https://roadmap.sh/ai](https://roadmap.sh/ai) 17 | 18 | 19 | -------------------------------------------------------------------------------- /coens-ai-notes/experiments/MCP-hands-on.qmd: -------------------------------------------------------------------------------- 1 | # MCP hands-on 2 | 3 | Diving in... 4 | 5 | So MCP standardizes the way I can combine sources of info (like RAG?) with an LLM. 6 | 7 | Duckduckgoing for 'MCP vs ollama hands-on' 8 | (adding CLI afterwards) gives me some links to look at, 9 | and after a closer look these still seem interesting: 10 | 11 | - [agentic-rag-and-mcp](https://becomingahacker.org/integrating-agentic-rag-with-mcp-servers-technical-implementation-guide-1aba8fd4e442) 12 | - [Ollama MCP bridge](https://mcp.so/server/ollama-mcp-bridge) 13 | - [ollama-mcp](https://github.com/rawveg/ollama-mcp) 14 | - [https://modelcontextprotocol.io/introduction](https://modelcontextprotocol.io/introduction) 15 | - [lazy terminal](https://mcp.so/server/Lazy_Terminal/Heterohabilis) 16 | - [https://apidog.com/blog/neovim-mcp-server/](https://apidog.com/blog/neovim-mcp-server/) 17 | 18 | # to look at still: 19 | 20 | - [agentic-rag-and-mcp](https://becomingahacker.org/integrating-agentic-rag-with-mcp-servers-technical-implementation-guide-1aba8fd4e442) 21 | - [Ollama MCP bridge](https://mcp.so/server/ollama-mcp-bridge) 22 | - [ollama-mcp](https://github.com/rawveg/ollama-mcp) 23 | - [https://modelcontextprotocol.io/introduction](https://modelcontextprotocol.io/introduction) 24 | - [lazy terminal](https://mcp.so/server/Lazy_Terminal/Heterohabilis) 25 | - [https://apidog.com/blog/neovim-mcp-server/](https://apidog.com/blog/neovim-mcp-server/) 26 | 27 | 28 | First I need an MCP client and an MCP server. 29 | 30 | # MCP Client 31 | 32 | - [5ire](https://github.com/nanbingxyz/5ire) looks nice. 33 | 34 | - [oterm](https://github.com/ggozad/oterm) 35 | 36 | 37 | -------------------------------------------------------------------------------- /coens-ai-notes/experiments/references.qmd: -------------------------------------------------------------------------------- 1 | # Experiments 2 | 3 | Experiments, maybe incomplete... never finished, the whole reutemeteut! 4 | -------------------------------------------------------------------------------- /coens-ai-notes/finetune.qmd: -------------------------------------------------------------------------------- 1 | # Finetune 2 | 3 | 4 | -------------------------------------------------------------------------------- /coens-ai-notes/fix_frontmatter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for file in *.qmd; do 4 | # Get the title from the first line that starts with # 5 | title=$(grep -m 1 '^# ' "$file" | sed 's/^# //') 6 | 7 | if [ -z "$title" ]; then 8 | # If no title found, use the filename 9 | title=$(basename "$file" .qmd) 10 | fi 11 | 12 | # Create a temporary file 13 | temp_file=$(mktemp) 14 | 15 | # Add clean YAML frontmatter 16 | echo "---" > "$temp_file" 17 | echo "title: \"$title\"" >> "$temp_file" 18 | echo "---" >> "$temp_file" 19 | echo "" >> "$temp_file" 20 | 21 | # Add the content, skipping any existing YAML frontmatter 22 | awk ' 23 | BEGIN { in_yaml=0; found_first_yaml=0 } 24 | /^---$/ { 25 | if (!found_first_yaml) { 26 | in_yaml=1; 27 | found_first_yaml=1; 28 | } else if (in_yaml) { 29 | in_yaml=0; 30 | } 31 | next; 32 | } 33 | !in_yaml && !/^title:/ { print } 34 | ' "$file" >> "$temp_file" 35 | 36 | # Replace the original file with the new content 37 | mv "$temp_file" "$file" 38 | 39 | echo "Fixed frontmatter in $file" 40 | done -------------------------------------------------------------------------------- /coens-ai-notes/fix_image_paths.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Fix image paths in all qmd files 4 | for file in *.qmd; do 5 | # Create a temporary file 6 | temp_file=$(mktemp) 7 | 8 | # Replace image paths 9 | sed 's|!\[\](workshop-AI/agile-ai-as-markdownpages/attach/|![](attach/|g' "$file" > "$temp_file" 10 | 11 | # Replace the original file 12 | mv "$temp_file" "$file" 13 | echo "Fixed image paths in $file" 14 | done -------------------------------------------------------------------------------- /coens-ai-notes/genai.qmd: -------------------------------------------------------------------------------- 1 | # GenAI 2 | 3 | Recent: 4 | 5 | - [Amy Webb SxSW 2025 - Emerging Tech Trend](https://www.youtube.com/watch?v=oT33_MrqyHo) 6 | 7 | ## What is GenAI? 8 | 9 | - Why not ask [perplexity.ai](https://www.perplexity.ai/) ? 10 | 11 | ## GPT - Generative Pre-Trained Transformer 12 | 13 | - [Generative AI & the Transformer (Financial Times, interactive site)](https://ig.ft.com/generative-ai/) 14 | - [History of ChatGPT (30 min)](https://www.youtube.com/watch?v=OFS90-FX6pg) 15 | - [But what is a GPT? (3Blue1Brown, 30 min)](https://www.youtube.com/watch?v=wjZofJX0v4M) 16 | 17 | ## Prompting 18 | 19 | - [Prompting basics](https://www.promptingguide.ai/introduction/basics) 20 | - [Prompting ChatGPT4.1](https://x.com/gregisenberg/status/1912298263987757296?s=48) 21 | - [Look for course with 'Prompting' in name: https://www.deeplearning.ai/short-courses/](https://www.deeplearning.ai/short-courses/) 22 | 23 | ## Hallucinating 24 | 25 | 26 | 27 | - 'Which day do I have to put the garbage can out on the street?' 28 | - 'Can you help me find my lost keys?' 29 | - 'Can you create an image of a watch that says it is 3 o' clock?' 30 | 31 | 32 | ## RAG - Retrieval Augmented Generation 33 | 34 | - [IBM, Marina Danilevsky (7 min)](https://www.youtube.com/watch?v=T-D1OfcDW1M) 35 | - [https://www.deeplearning.ai/short-courses: Great resource for courses!](https://www.deeplearning.ai/short-courses/) 36 | 37 | ## Active Inference 38 | 39 | - [Andy Clark about Active Interference: How the Brains shapes reality (60 min)](https://www.youtube.com/watch?v=A1Ghrd7NBtk) 40 | 41 | ## Running LLM's locally 42 | 43 | On your laptop/desktop or on a company server: 44 | 45 | - [ollama](https://ollama.com/) 46 | - [LM-studio](https://lmstudio.ai/) 47 | - [Open Web AI](https://docs.openwebui.com/) 48 | 49 | ## Coding with GenAI 50 | 51 | - [vs code with co-pilot (free plan)](https://code.visualstudio.com/docs/copilot/overview) 52 | - [Cursor.com (20 euro p/m)](https://cursor.com) 53 | - [AIDER.chat (free)](https://aider.chat/) 54 | - [Open Devin: Create any Application with Open Source AI Engineer](https://www.youtube.com/watch?v=3-q5GzRNEe0) 55 | - [Avante (AI in neovim, free)](https://nithinbekal.com/posts/avante-nvim/) 56 | 57 | ## MCP - Model Context Protocol 58 | 59 | A way (AI) systems can communicate to each other. 60 | This way it helps building modular (AI) systems. 61 | 62 | - [MCP Quickstart](https://modelcontextprotocol.info/docs/quickstart/quickstart/) 63 | - [Short deeplearning.ai course MCP](https://learn.deeplearning.ai/courses/mcp-build-rich-context-ai-apps-with-anthropic/lesson/fkbhh/introduction) 64 | 65 | ## GenAI 66 | 67 | - [awesome GenAI guide](https://github.com/aishwaryanr/awesome-generative-ai-guide) 68 | - [huggingface](https://huggingface.co/) 69 | 70 | ## Some more sites, nice to play around with 71 | 72 | - [https://skyreels.ai/](https://skyreels.ai/) 73 | - [https://civitai.com/](https://civitai.com/) 74 | -------------------------------------------------------------------------------- /coens-ai-notes/index.AI.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "index.AI" 3 | --- 4 | 5 | - [ai.overview](ai.overview.md) 6 | 7 | ## Perceptron to Neural Network: how does it work? 8 | 9 | - [perceptron](perceptron.md) 10 | - [applying the perceptron](applying_the_perceptron.md) 11 | - [Decision-making](Decision-making.md) 12 | - [The-learning-Perceptron](The-learning-Perceptron.md) 13 | - [Problem-with-perceptron](Problem-with-perceptron.md) 14 | - [neural-network](neural-network.md) 15 | - [Classifying-Iris](Classifying-Iris.md) 16 | - [Magic-behind-NNetwork](Magic-behind-NNetwork.md) 17 | 18 | 19 | - [Types-NN](Types-NN.md) 20 | - [OK what's next?](OK-Next.md) 21 | - [Learning-Python](Learning-Python.md) 22 | - [Finding-Data](Finding-Data.md) 23 | - [References](workshop-AI/agile-ai-as-markdownpages/References.md) 24 | 25 | 26 | -------------------------------------------------------------------------------- /coens-ai-notes/index.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction" 3 | --- 4 | 5 | Welcome! This is a Work-in-Progress, a collection of notes on AI 6 | I am collecting and which I use in my workshops about AI and GenAI. 7 | The newest version of this pdf can be downloaded from 8 | [here](https://github.com/coentjo/agile-ai-in-pharo/blob/master/coens-ai-notes/_output) 9 | 10 | It is not complete nor self-describing, 11 | but when 12 | you attended one of my workshops you will probably find familiar 13 | stuff in one or more chapters. 14 | 15 | Our world is changing rapidly through AI and GenAI. One can ignore it or decide to not use it, 16 | but that does not stop it... One can also decide to dive in and help 'invent' the future, or 17 | at least learn about all the new stuff. 18 | 19 | 20 | These notes started out as visualizations of Perceptrons and Neural 21 | Networks in the Glamorous Toolkit, which helped me give students insights 22 | in Neural Networks. 23 | 24 | I advise to get hands-on with the tools around. 25 | 26 | When using online AI tools, please keep the privacy in mind when 27 | using personal data! One way to make sure private data will stay 28 | private is using local AI's. 29 | 30 | Please also keep the Societal impact in mind! 31 | We can use AI to help us all, but there is of course also a dark side: 32 | People getting fired, 33 | it's easier to create fake news, 34 | a few people getting rich at the expense of others, 35 | some nice activities (I like programming for example) will never be the same. 36 | Please use it wisely... 37 | 38 | ![art and laundry](ai.laundry.art.maciejewska.jpg) 39 | -------------------------------------------------------------------------------- /coens-ai-notes/journalism.ai.qmd: -------------------------------------------------------------------------------- 1 | # Journalism and AI 2 | 3 | - [Hey Aftonbladet (chatbot): What do YOU want to know?](https://www.journalismai.info/blog/what-do-you-want-to-know) 4 | -------------------------------------------------------------------------------- /coens-ai-notes/mcp.qmd: -------------------------------------------------------------------------------- 1 | # MCP - Model Context Protocol 2 | 3 | MCP is a standardization of the way to how LLM's connect to other tools. 4 | 5 | - [modelcontextprotocol.info/](https://modelcontextprotocol.info/) 6 | - [Example Clients](https://modelcontextprotocol.io/clients) 7 | - [Servers](https://github.com/modelcontextprotocol/servers) 8 | - [Greg Isenberg/Ras Mic explaining MCP](https://www.youtube.com/watch?v=7j_NE6Pjv-E) 9 | - [short course MCP at deeplearning.ai](https://learn.deeplearning.ai/courses/mcp-build-rich-context-ai-apps-with-anthropic) 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /coens-ai-notes/neural-network.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to Neural Networks" 3 | --- 4 | 5 | ## Beyond Single Perceptrons: Building Neural Networks 6 | 7 | Having seen the limitations of single Perceptrons, we now venture into the fascinating world of neural networks. These powerful structures combine multiple Perceptrons in layers to solve complex problems that single Perceptrons cannot handle. 8 | 9 | ![Basic neural network architecture](attach/2021-AI-General.041.png) 10 | 11 | ## Understanding Network Architecture 12 | 13 | A typical neural network consists of three main components: 14 | 15 | 1. **Input Layer**: Receives the raw data 16 | 2. **Hidden Layer(s)**: Processes the information through multiple Perceptrons 17 | 3. **Output Layer**: Produces the final result 18 | 19 | ### Key Components 20 | 21 | Each connection in the network has: 22 | - A weight that determines its strength 23 | - A direction of information flow (forward only) 24 | - An associated neuron that processes the incoming signals 25 | 26 | ## How Information Flows 27 | 28 | The network processes information in these steps: 29 | 30 | 1. Input values are presented to the input layer 31 | 2. Each neuron in subsequent layers: 32 | - Receives weighted inputs from the previous layer 33 | - Applies its activation function 34 | - Passes the result to the next layer 35 | 3. The output layer produces the final result 36 | 37 | ## Creating a Simple Network 38 | 39 | You probably have seen a picture of a neural network before. 40 | 41 | 42 | 43 | Neural Networks can 44 | 45 | 1. solve problems that are more difficult. 46 | 2. Handle complex pattern recognition 47 | 3. Learn hierarchical features automatically 48 | 4. Scale well to large problems 49 | 50 | In the next sections, we'll explore practical applications and see how to train networks on real-world data. 51 | -------------------------------------------------------------------------------- /coens-ai-notes/nocodelowcode.qmd: -------------------------------------------------------------------------------- 1 | # No-Code / Low Code 2 | 3 | Worth looking at: 4 | 5 | - [docs.oap.langchain.com](https://docs.oap.langchain.com/) 6 | - [n8n.io](https://n8n.io/) 7 | - [flowai.cc](https://flowai.cc/en/) -------------------------------------------------------------------------------- /coens-ai-notes/rag.qmd: -------------------------------------------------------------------------------- 1 | # RAG: Retrieval Augmented Generation 2 | 3 | 4 | -------------------------------------------------------------------------------- /coens-ai-notes/references.ai.act.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "AI Act Resources and References" 3 | --- 4 | 5 | - [youtube 4min: How is Europe becoming a leader in AI?](https://www.youtube.com/watch?v=i268oenkv0U) 6 | - [SURF startdocument AI Act](https://www.surf.nl/files/2025-03/startdocument-ai-act-b5-1.pdf) 7 | -------------------------------------------------------------------------------- /coens-ai-notes/references.ai.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Resources and References AI" 3 | --- 4 | 5 | ## Books 6 | 7 | 1. **Neural Networks and Deep Learning** 8 | 9 | - Author: Michael Nielsen 10 | - [Free Online Book](http://neuralnetworksanddeeplearning.com) 11 | - Perfect for beginners and intermediate learners 12 | - Clear explanations with interactive examples 13 | 14 | 2. **Deep Learning** 15 | 16 | - Authors: Ian Goodfellow, Yoshua Bengio, Aaron Courville 17 | - [Available Online](https://www.deeplearningbook.org) 18 | - Comprehensive coverage of deep learning 19 | - Industry standard reference 20 | 21 | 3. **Agile AI in Pharo** 22 | 23 | - Author: Alexandre Bergel 24 | - Practical implementation in Pharo 25 | - Hands-on examples and exercises 26 | - [Book Link](https://books.pharo.org/) 27 | 28 | ## Video Courses and Tutorials 29 | 30 | ### 1. Foundational Series 31 | 32 | - [3Blue1Brown Neural Networks](https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi) 33 | 34 | - Visual explanations 35 | - Mathematical intuition 36 | - Clear animations 37 | 38 | https://www.youtube.com/watch?v=O5xeyoRL95U 39 | 40 | ### 2. Programming Tutorials 41 | 42 | - [Fast.ai Deep Learning Course](https://course.fast.ai) 43 | 44 | - Practical approach 45 | - Top-down learning 46 | - Real-world applications 47 | 48 | ### 3. Advanced Topics 49 | 50 | - [Stanford CS231n](http://cs231n.stanford.edu) 51 | - Computer Vision 52 | - Deep Learning 53 | - State-of-the-art techniques 54 | 55 | ## Online Platforms 56 | 57 | ### 1. Interactive Learning 58 | 59 | - [Kaggle Learn](https://www.kaggle.com/learn) 60 | - Hands-on exercises 61 | - Real datasets 62 | - Community support 63 | 64 | ### 2. Research Papers 65 | 66 | - [arXiv Machine Learning](https://arxiv.org/list/cs.LG/recent) 67 | - Latest research 68 | - Open access 69 | - Preprint server 70 | 71 | ### 3. Code Repositories 72 | 73 | - [Papers With Code](https://paperswithcode.com) 74 | - Implementations of papers 75 | - Benchmarks 76 | - State-of-the-art tracking 77 | 78 | ## Community Resources 79 | 80 | ### 1. Forums and Discussion 81 | 82 | - [r/MachineLearning](https://reddit.com/r/MachineLearning) 83 | - [Cross Validated](https://stats.stackexchange.com) 84 | - [AI Stack Exchange](https://ai.stackexchange.com) 85 | 86 | ### 2. Blogs and Newsletters 87 | 88 | - [Distill.pub](https://distill.pub) 89 | - Interactive explanations 90 | - Visual learning 91 | - Deep insights 92 | 93 | ### 3. Tools and Libraries 94 | 95 | - [TensorFlow](https://tensorflow.org) 96 | - [PyTorch](https://pytorch.org) 97 | - [Scikit-learn](https://scikit-learn.org) 98 | 99 | ## Academic Papers 100 | 101 | ### Foundational Papers 102 | 103 | - "A Logical Calculus of Ideas Immanent in Nervous Activity" (McCulloch & Pitts, 1943) 104 | - "Learning Internal Representations by Error Propagation" (Rumelhart et al., 1986) 105 | - "Gradient-Based Learning Applied to Document Recognition" (LeCun et al., 1998) 106 | 107 | -------------------------------------------------------------------------------- /coens-ai-notes/references.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/coens-ai-notes/references.bib -------------------------------------------------------------------------------- /coens-ai-notes/references.genai.qmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Resources and References GenAI" 3 | --- 4 | 5 | ## Blogs and articles 6 | 7 | Perplexity is often a great start for finding things (with references): [perplexity.ai](https://www.perplexity.ai/) 8 | 9 | - [Jessy: Het belang van duidelijke AI-prompts](https://www.jessydecooker.nl/?p=12877) 10 | - [Journalists on Hugging Face](https://huggingface.co/spaces/JournalistsonHF/ai-toolkit) 11 | - [How polite should we be when prompting LLMs?](https://www.prompthub.us/blog/how-polite-should-we-be-when-prompting-llms) 12 | - [Information literacy and chatbots as search](https://buttondown.com/maiht3k/archive/information-literacy-and-chatbots-as-search) 13 | 14 | To understand about Transformers this is a very nice start: https://ig.ft.com/generative-ai/ 15 | 'Our own' page about (Gen)AI: https://stasemsoft.github.io/FontysICT-sem1/docs/artificial-intelligence/ai.html 16 | To dive further into how Transformers works: https://www.deeplearning.ai/short-courses/how-transformer-llms-work/ 17 | and also to other short courses on deeplearning.ai 18 | The development I showed was https://www.cursor.com/ 19 | you have like only 500 requests for free... after that you could choose to pay 20 euro a Month (yes, that can be a lot for students, I know), or look for alternatives, 2 of which I tried a bit (you can use local LLM's with them, which basically makes them free): 20 | AIDER: https://aider.chat/. 21 | Avante: https://github.com/yetone/avante.nvim (but then you need to learn about 'vi': https://neovim.io/ which is a hurdle). 22 | 23 | ## Online Platforms 24 | 25 | ### (Short) Courses 26 | - [Short courses at Deeplearning.ai](https://www.deeplearning.ai/courses/) 27 | - Implementations of papers 28 | - Benchmarks 29 | - State-of-the-art tracking 30 | 31 | ### Code Repositories 32 | 33 | - [Papers With Code](https://paperswithcode.com) 34 | - Implementations of papers 35 | - Benchmarks 36 | - State-of-the-art tracking 37 | 38 | ## Community Resources 39 | 40 | - [Distill.pub](https://distill.pub) 41 | - Interactive explanations 42 | - Visual learning 43 | - Deep insights 44 | 45 | ## Academic Papers 46 | 47 | ### Modern Breakthroughs 48 | - "Deep Residual Learning for Image Recognition" (He et al., 2015) 49 | - "Attention Is All You Need" (Vaswani et al., 2017) 50 | - "Language Models are Few-Shot Learners" (Brown et al., 2020) 51 | 52 | -------------------------------------------------------------------------------- /coens-ai-notes/train-finetune-rag.qmd: -------------------------------------------------------------------------------- 1 | # Train, Fine Tune, RAG 2 | 3 | Several ways to 'teach' the AI about the knowledge it needs to 4 | perform the task you need it for. The most easy of these is 5 | building a RAG system: Retrieval Augmented Generation. 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /coens-ai-notes/train.qmd: -------------------------------------------------------------------------------- 1 | # Training 2 | 3 | Training a model from scratch is a complex and resource-intensive process. 4 | It involves collecting a large dataset, preprocessing the data, 5 | and training the model using powerful hardware. This is typically done by large organizations with significant resources. 6 | 7 | [short course: fine tuning](https://learn.deeplearning.ai/courses/finetuning-large-language-models) 8 | 9 | -------------------------------------------------------------------------------- /errata.md: -------------------------------------------------------------------------------- 1 | # Errata for *Book Title* 2 | 3 | On **page xx** [Summary of error]: 4 | 5 | Details of error here. Highlight key pieces in **bold**. 6 | 7 | *** 8 | 9 | On **page xx** [Summary of error]: 10 | 11 | Details of error here. Highlight key pieces in **bold**. 12 | 13 | *** -------------------------------------------------------------------------------- /findings.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | By giving the example-methods a name starting with 'test' some (most?) will be usable also from Pharo9. 4 | 5 | ```Smalltalk 6 | testChapter02Example01 7 | 8 | ^ #(1 2 3) 9 | with: #(10 20 30) 10 | collect: [ :a :b | a + b ] 11 | ``` 12 | -------------------------------------------------------------------------------- /img/9781484253830.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/9781484253830.jpg -------------------------------------------------------------------------------- /img/GT.Classifying-dots-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.Classifying-dots-line.png -------------------------------------------------------------------------------- /img/GT.Fed.Neuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.Fed.Neuron.png -------------------------------------------------------------------------------- /img/GT.NeuralNetwork-detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.NeuralNetwork-detail.png -------------------------------------------------------------------------------- /img/GT.NeuralNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.NeuralNetwork.png -------------------------------------------------------------------------------- /img/GT.Sigmoid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.Sigmoid.png -------------------------------------------------------------------------------- /img/GT.git.load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.git.load.png -------------------------------------------------------------------------------- /img/GT.git.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.git.png -------------------------------------------------------------------------------- /img/GT.lepiter.WorkshopAI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.lepiter.WorkshopAI.png -------------------------------------------------------------------------------- /img/GT.lepiter.newDatabase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.lepiter.newDatabase.png -------------------------------------------------------------------------------- /img/GT.lepiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/img/GT.lepiter.png -------------------------------------------------------------------------------- /index.qmd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/index.qmd -------------------------------------------------------------------------------- /lepiter.properties: -------------------------------------------------------------------------------- 1 | { 2 | "uuid" : "b146574e-6f8c-0d00-88a7-be3c02b7b242", 3 | "schema" : "4.1" 4 | } -------------------------------------------------------------------------------- /lepiter/3lszqrc4rkn0fuuhnon2do41x.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ 7 | { 8 | "__type" : "textSnippet", 9 | "children" : { 10 | "__type" : "snippets", 11 | "items" : [ ] 12 | }, 13 | "createEmail" : { 14 | "__type" : "email", 15 | "emailString" : "" 16 | }, 17 | "createTime" : { 18 | "__type" : "time", 19 | "time" : { 20 | "__type" : "dateAndTime", 21 | "dateAndTimeString" : "2022-03-19T13:58:23.949781+01:00" 22 | } 23 | }, 24 | "editEmail" : { 25 | "__type" : "email", 26 | "emailString" : "" 27 | }, 28 | "editTime" : { 29 | "__type" : "time", 30 | "time" : { 31 | "__type" : "dateAndTime", 32 | "dateAndTimeString" : "2022-03-19T13:58:23.949781+01:00" 33 | } 34 | }, 35 | "uid" : { 36 | "__type" : "uid", 37 | "uidString" : "ALgvjvOWDQCSuDwRA5nnPA==" 38 | }, 39 | "paragraphStyle" : { 40 | "__type" : "textStyle" 41 | }, 42 | "string" : "" 43 | }, 44 | { 45 | "__type" : "pictureSnippet", 46 | "children" : { 47 | "__type" : "snippets", 48 | "items" : [ ] 49 | }, 50 | "createEmail" : { 51 | "__type" : "email", 52 | "emailString" : "" 53 | }, 54 | "createTime" : { 55 | "__type" : "time", 56 | "time" : { 57 | "__type" : "dateAndTime", 58 | "dateAndTimeString" : "2022-03-19T13:58:31.300208+01:00" 59 | } 60 | }, 61 | "editEmail" : { 62 | "__type" : "email", 63 | "emailString" : "" 64 | }, 65 | "editTime" : { 66 | "__type" : "time", 67 | "time" : { 68 | "__type" : "dateAndTime", 69 | "dateAndTimeString" : "2024-09-14T15:29:42.529427+02:00" 70 | } 71 | }, 72 | "uid" : { 73 | "__type" : "uid", 74 | "uidString" : "nuCfjvOWDQCSuqtJA5nnPA==" 75 | }, 76 | "url" : "attachments/3lszqra6jy6fswevlyq0nbwwp/screenshot-appetizer.png", 77 | "caption" : "", 78 | "previewHeight" : 300 79 | } 80 | ] 81 | }, 82 | "createEmail" : { 83 | "__type" : "email", 84 | "emailString" : "" 85 | }, 86 | "createTime" : { 87 | "__type" : "time", 88 | "time" : { 89 | "__type" : "dateAndTime", 90 | "dateAndTimeString" : "2022-03-19T13:58:23.906791+01:00" 91 | } 92 | }, 93 | "editEmail" : { 94 | "__type" : "email", 95 | "emailString" : "" 96 | }, 97 | "editTime" : { 98 | "__type" : "time", 99 | "time" : { 100 | "__type" : "dateAndTime", 101 | "dateAndTimeString" : "2022-03-19T13:58:23.906791+01:00" 102 | } 103 | }, 104 | "pageType" : { 105 | "__type" : "namedPage", 106 | "title" : "screenshot" 107 | }, 108 | "uid" : { 109 | "__type" : "uuid", 110 | "uuid" : "850f2f8e-f396-0d00-92b7-93ef0399e73c" 111 | } 112 | } -------------------------------------------------------------------------------- /lepiter/464egypsplgdeko8towogisqh.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ ] 7 | }, 8 | "createEmail" : { 9 | "__type" : "email", 10 | "emailString" : "" 11 | }, 12 | "createTime" : { 13 | "__type" : "time", 14 | "time" : { 15 | "__type" : "dateAndTime", 16 | "dateAndTimeString" : "2024-08-24T15:36:54.99362+02:00" 17 | } 18 | }, 19 | "editEmail" : { 20 | "__type" : "email", 21 | "emailString" : "" 22 | }, 23 | "editTime" : { 24 | "__type" : "time", 25 | "time" : { 26 | "__type" : "dateAndTime", 27 | "dateAndTimeString" : "2024-08-31T16:41:45.75757+02:00" 28 | } 29 | }, 30 | "pageType" : { 31 | "__type" : "namedPage", 32 | "title" : "Some References" 33 | }, 34 | "uid" : { 35 | "__type" : "uuid", 36 | "uuid" : "f9d1dbb8-cfdc-0d00-b407-5b1a02f86f46" 37 | } 38 | } -------------------------------------------------------------------------------- /lepiter/464egyqjhgitq54s20oquakka.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ ] 7 | }, 8 | "createEmail" : { 9 | "__type" : "email", 10 | "emailString" : "" 11 | }, 12 | "createTime" : { 13 | "__type" : "time", 14 | "time" : { 15 | "__type" : "dateAndTime", 16 | "dateAndTimeString" : "2024-08-24T15:10:33.526774+02:00" 17 | } 18 | }, 19 | "editEmail" : { 20 | "__type" : "email", 21 | "emailString" : "" 22 | }, 23 | "editTime" : { 24 | "__type" : "time", 25 | "time" : { 26 | "__type" : "dateAndTime", 27 | "dateAndTimeString" : "2024-08-24T15:10:33.526774+02:00" 28 | } 29 | }, 30 | "pageType" : { 31 | "__type" : "namedPage", 32 | "title" : "Intro" 33 | }, 34 | "uid" : { 35 | "__type" : "uuid", 36 | "uuid" : "9a8c985a-cfdc-0d00-a261-243302f86f46" 37 | } 38 | } -------------------------------------------------------------------------------- /lepiter/464egysyt3si0kfd2yddat9ug.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ ] 7 | }, 8 | "createEmail" : { 9 | "__type" : "email", 10 | "emailString" : "" 11 | }, 12 | "createTime" : { 13 | "__type" : "time", 14 | "time" : { 15 | "__type" : "dateAndTime", 16 | "dateAndTimeString" : "2024-08-24T15:34:00.009258+02:00" 17 | } 18 | }, 19 | "editEmail" : { 20 | "__type" : "email", 21 | "emailString" : "" 22 | }, 23 | "editTime" : { 24 | "__type" : "time", 25 | "time" : { 26 | "__type" : "dateAndTime", 27 | "dateAndTimeString" : "2024-08-24T15:34:00.009258+02:00" 28 | } 29 | }, 30 | "pageType" : { 31 | "__type" : "namedPage", 32 | "title" : "Workshop" 33 | }, 34 | "uid" : { 35 | "__type" : "uuid", 36 | "uuid" : "18c56dae-cfdc-0d00-b2ca-fb8302f86f46" 37 | } 38 | } -------------------------------------------------------------------------------- /lepiter/464egyuhpf8zolyefjn7fe0uy.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ 7 | { 8 | "__type" : "textSnippet", 9 | "children" : { 10 | "__type" : "snippets", 11 | "items" : [ ] 12 | }, 13 | "createEmail" : { 14 | "__type" : "email", 15 | "emailString" : "" 16 | }, 17 | "createTime" : { 18 | "__type" : "time", 19 | "time" : { 20 | "__type" : "dateAndTime", 21 | "dateAndTimeString" : "2024-08-24T15:33:45.856844+02:00" 22 | } 23 | }, 24 | "editEmail" : { 25 | "__type" : "email", 26 | "emailString" : "" 27 | }, 28 | "editTime" : { 29 | "__type" : "time", 30 | "time" : { 31 | "__type" : "dateAndTime", 32 | "dateAndTimeString" : "2024-08-24T15:33:55.486557+02:00" 33 | } 34 | }, 35 | "uid" : { 36 | "__type" : "uid", 37 | "uidString" : "ZdOVrc/cDQCyZBuPAvhvRg==" 38 | }, 39 | "paragraphStyle" : { 40 | "__type" : "textStyle" 41 | }, 42 | "string" : "We'll see... ;-) " 43 | }, 44 | { 45 | "__type" : "textSnippet", 46 | "children" : { 47 | "__type" : "snippets", 48 | "items" : [ ] 49 | }, 50 | "createEmail" : { 51 | "__type" : "email", 52 | "emailString" : "" 53 | }, 54 | "createTime" : { 55 | "__type" : "time", 56 | "time" : { 57 | "__type" : "dateAndTime", 58 | "dateAndTimeString" : "2024-08-24T15:33:55.85749+02:00" 59 | } 60 | }, 61 | "editEmail" : { 62 | "__type" : "email", 63 | "emailString" : "" 64 | }, 65 | "editTime" : { 66 | "__type" : "time", 67 | "time" : { 68 | "__type" : "dateAndTime", 69 | "dateAndTimeString" : "2024-08-24T15:33:55.85749+02:00" 70 | } 71 | }, 72 | "uid" : { 73 | "__type" : "uid", 74 | "uidString" : "cmours/cDQCyxqMiAvhvRg==" 75 | }, 76 | "paragraphStyle" : { 77 | "__type" : "textStyle" 78 | }, 79 | "string" : "" 80 | } 81 | ] 82 | }, 83 | "createEmail" : { 84 | "__type" : "email", 85 | "emailString" : "" 86 | }, 87 | "createTime" : { 88 | "__type" : "time", 89 | "time" : { 90 | "__type" : "dateAndTime", 91 | "dateAndTimeString" : "2024-08-24T15:33:45.808854+02:00" 92 | } 93 | }, 94 | "editEmail" : { 95 | "__type" : "email", 96 | "emailString" : "" 97 | }, 98 | "editTime" : { 99 | "__type" : "time", 100 | "time" : { 101 | "__type" : "dateAndTime", 102 | "dateAndTimeString" : "2024-08-24T15:33:45.808854+02:00" 103 | } 104 | }, 105 | "pageType" : { 106 | "__type" : "namedPage", 107 | "title" : "4. Can we see some of that learning in action?" 108 | }, 109 | "uid" : { 110 | "__type" : "uuid", 111 | "uuid" : "da1695ad-cfdc-0d00-b263-ceb602f86f46" 112 | } 113 | } -------------------------------------------------------------------------------- /lepiter/464egyv8mnjucjplumnx2oxwd.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ 7 | { 8 | "__type" : "textSnippet", 9 | "children" : { 10 | "__type" : "snippets", 11 | "items" : [ ] 12 | }, 13 | "createEmail" : { 14 | "__type" : "email", 15 | "emailString" : "" 16 | }, 17 | "createTime" : { 18 | "__type" : "time", 19 | "time" : { 20 | "__type" : "dateAndTime", 21 | "dateAndTimeString" : "2024-09-19T12:12:56.94586+02:00" 22 | } 23 | }, 24 | "editEmail" : { 25 | "__type" : "email", 26 | "emailString" : "" 27 | }, 28 | "editTime" : { 29 | "__type" : "time", 30 | "time" : { 31 | "__type" : "dateAndTime", 32 | "dateAndTimeString" : "2024-09-19T12:13:54.366663+02:00" 33 | } 34 | }, 35 | "uid" : { 36 | "__type" : "uid", 37 | "uidString" : "eKRV5dfeDQCzP4PLCWzPAw==" 38 | }, 39 | "paragraphStyle" : { 40 | "__type" : "textStyle" 41 | }, 42 | "string" : "Now that we extended Perceptrons to Neurons we can combine Neurons together into a Network. " 43 | } 44 | ] 45 | }, 46 | "createEmail" : { 47 | "__type" : "email", 48 | "emailString" : "" 49 | }, 50 | "createTime" : { 51 | "__type" : "time", 52 | "time" : { 53 | "__type" : "dateAndTime", 54 | "dateAndTimeString" : "2024-08-24T15:32:34.833607+02:00" 55 | } 56 | }, 57 | "editEmail" : { 58 | "__type" : "email", 59 | "emailString" : "" 60 | }, 61 | "editTime" : { 62 | "__type" : "time", 63 | "time" : { 64 | "__type" : "dateAndTime", 65 | "dateAndTimeString" : "2024-08-24T15:32:34.833607+02:00" 66 | } 67 | }, 68 | "pageType" : { 69 | "__type" : "namedPage", 70 | "title" : "3. How can we combine neurons in a network that can learn?" 71 | }, 72 | "uid" : { 73 | "__type" : "uuid", 74 | "uuid" : "9d175aa9-cfdc-0d00-b113-bbcf02f86f46" 75 | } 76 | } -------------------------------------------------------------------------------- /lepiter/62kynqubeaj4pm1uvbv29tt4g.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ 7 | { 8 | "__type" : "pharoSnippet", 9 | "children" : { 10 | "__type" : "snippets", 11 | "items" : [ ] 12 | }, 13 | "createEmail" : { 14 | "__type" : "email", 15 | "emailString" : "" 16 | }, 17 | "createTime" : { 18 | "__type" : "time", 19 | "time" : { 20 | "__type" : "dateAndTime", 21 | "dateAndTimeString" : "2022-08-18T13:34:18.531+02:00" 22 | } 23 | }, 24 | "editEmail" : { 25 | "__type" : "email", 26 | "emailString" : "" 27 | }, 28 | "editTime" : { 29 | "__type" : "time", 30 | "time" : { 31 | "__type" : "dateAndTime", 32 | "dateAndTimeString" : "2022-08-18T13:34:24.928+02:00" 33 | } 34 | }, 35 | "uid" : { 36 | "__type" : "uid", 37 | "uidString" : "uLxVGeSiDQCoXeoKBA+PZg==" 38 | }, 39 | "code" : "\"These slides contain all the example scripts for a chapter from the book\"\r(GtLiveShow create: WASlidesFinal new) makeArrowsVisible " 40 | } 41 | ] 42 | }, 43 | "createEmail" : { 44 | "__type" : "email", 45 | "emailString" : "" 46 | }, 47 | "createTime" : { 48 | "__type" : "time", 49 | "time" : { 50 | "__type" : "dateAndTime", 51 | "dateAndTimeString" : "2022-08-18T13:34:05.039+02:00" 52 | } 53 | }, 54 | "editEmail" : { 55 | "__type" : "email", 56 | "emailString" : "" 57 | }, 58 | "editTime" : { 59 | "__type" : "time", 60 | "time" : { 61 | "__type" : "dateAndTime", 62 | "dateAndTimeString" : "2022-08-18T13:34:05.039+02:00" 63 | } 64 | }, 65 | "pageType" : { 66 | "__type" : "namedPage", 67 | "title" : "concluding" 68 | }, 69 | "uid" : { 70 | "__type" : "uuid", 71 | "uuid" : "b0d98718-e4a2-0d00-a85a-1326040f8f66" 72 | } 73 | } -------------------------------------------------------------------------------- /lepiter/attachments/25ngvq19h53k4jqhaa5z4og3r/AI-Bergel-1-neuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/25ngvq19h53k4jqhaa5z4og3r/AI-Bergel-1-neuron.png -------------------------------------------------------------------------------- /lepiter/attachments/25ngvq19h53k4jqhaa5z4og3r/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2021-10-17T14:43:15.674768+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/3lszqra6jy6fswevlyq0nbwwp/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2022-03-19T13:58:51.433272+01:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/3lszqra6jy6fswevlyq0nbwwp/screenshot-appetizer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/3lszqra6jy6fswevlyq0nbwwp/screenshot-appetizer.png -------------------------------------------------------------------------------- /lepiter/attachments/506kjcde5gn8pi87kzqm6e1a9/AI-Bergel-2-perceptron 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/506kjcde5gn8pi87kzqm6e1a9/AI-Bergel-2-perceptron 1.png -------------------------------------------------------------------------------- /lepiter/attachments/506kjcde5gn8pi87kzqm6e1a9/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2021-10-17T14:46:11.055705+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/93mdx42tkirmyu6xep5pninz4/2021-AI-General.051.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/93mdx42tkirmyu6xep5pninz4/2021-AI-General.051.png -------------------------------------------------------------------------------- /lepiter/attachments/93mdx42tkirmyu6xep5pninz4/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-08-31T17:18:11.944549+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/93mdx43cuyk9ozqsnka2rswnb/2021-AI-General.049.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/93mdx43cuyk9ozqsnka2rswnb/2021-AI-General.049.png -------------------------------------------------------------------------------- /lepiter/attachments/93mdx43cuyk9ozqsnka2rswnb/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-08-31T17:34:25.162534+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/93mdx45vgrq9ult7mc0ug29re/2021-AI-General.052.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/93mdx45vgrq9ult7mc0ug29re/2021-AI-General.052.png -------------------------------------------------------------------------------- /lepiter/attachments/93mdx45vgrq9ult7mc0ug29re/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-08-31T17:03:36.485899+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/93mdx46vvditkr1u9395xa7an/2021-AI-General.050.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/93mdx46vvditkr1u9395xa7an/2021-AI-General.050.png -------------------------------------------------------------------------------- /lepiter/attachments/93mdx46vvditkr1u9395xa7an/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-08-31T17:19:02.747783+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/93mdx47z0l0xhikpfp5isfj3n/NeuralNetworks.Mobile-apps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/93mdx47z0l0xhikpfp5isfj3n/NeuralNetworks.Mobile-apps.png -------------------------------------------------------------------------------- /lepiter/attachments/93mdx47z0l0xhikpfp5isfj3n/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-08-31T16:48:04.489686+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/a2xz7edye9ovbir79lq915yby/TypicalNeuron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/a2xz7edye9ovbir79lq915yby/TypicalNeuron.png -------------------------------------------------------------------------------- /lepiter/attachments/a2xz7edye9ovbir79lq915yby/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2021-10-30T22:02:05.515087+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/a2xz7efdiumd2tb2rell119o8/Perceptron01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/a2xz7efdiumd2tb2rell119o8/Perceptron01.png -------------------------------------------------------------------------------- /lepiter/attachments/a2xz7efdiumd2tb2rell119o8/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2021-10-30T22:08:15.353467+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/acubx5qhgc7mewm9oe9ipmju5/2021-AI-General.039.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/acubx5qhgc7mewm9oe9ipmju5/2021-AI-General.039.png -------------------------------------------------------------------------------- /lepiter/attachments/acubx5qhgc7mewm9oe9ipmju5/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-09-02T19:56:17.774694+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/acubx5res3wwqqsoqpln3973l/2021-AI-General.040.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/acubx5res3wwqqsoqpln3973l/2021-AI-General.040.png -------------------------------------------------------------------------------- /lepiter/attachments/acubx5res3wwqqsoqpln3973l/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-09-02T19:58:45.057444+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/acubx5tw8s9pg69gxywngcd0d/2021-AI-General.034.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/acubx5tw8s9pg69gxywngcd0d/2021-AI-General.034.png -------------------------------------------------------------------------------- /lepiter/attachments/acubx5tw8s9pg69gxywngcd0d/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-09-02T19:46:40.255016+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/acubx5u98dal5skto751e2ub7/2021-AI-General.041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/acubx5u98dal5skto751e2ub7/2021-AI-General.041.png -------------------------------------------------------------------------------- /lepiter/attachments/acubx5u98dal5skto751e2ub7/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-09-02T19:38:44.164209+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/acubx5uloavw5osr26p7x3b60/2021-AI-General.038.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/acubx5uloavw5osr26p7x3b60/2021-AI-General.038.png -------------------------------------------------------------------------------- /lepiter/attachments/acubx5uloavw5osr26p7x3b60/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-09-02T19:55:51.253515+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/acubx5v6o9ka5u5phbhlcqnae/2021-AI-General.035.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/acubx5v6o9ka5u5phbhlcqnae/2021-AI-General.035.png -------------------------------------------------------------------------------- /lepiter/attachments/acubx5v6o9ka5u5phbhlcqnae/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-09-02T19:50:22.072309+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/attachments/cfq22ybf8bqck0thc6dzv2szj/2021-AI-General.044.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/lepiter/attachments/cfq22ybf8bqck0thc6dzv2szj/2021-AI-General.044.png -------------------------------------------------------------------------------- /lepiter/attachments/cfq22ybf8bqck0thc6dzv2szj/lepiter_attachment.properties: -------------------------------------------------------------------------------- 1 | {"__schema":"4.1","__type":"attachment","uploadDate":{"__type":"dateAndTime","dateAndTimeString":"2024-08-31T20:45:48.233523+02:00"},"uploadedBy":{"__type":"email","emailString":""}} -------------------------------------------------------------------------------- /lepiter/cgms9ex95d3nbntrbuof4al68.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ 7 | { 8 | "__type" : "textSnippet", 9 | "children" : { 10 | "__type" : "snippets", 11 | "items" : [ ] 12 | }, 13 | "createEmail" : { 14 | "__type" : "email", 15 | "emailString" : "" 16 | }, 17 | "createTime" : { 18 | "__type" : "time", 19 | "time" : { 20 | "__type" : "dateAndTime", 21 | "dateAndTimeString" : "2022-08-17T17:57:10.141+02:00" 22 | } 23 | }, 24 | "editEmail" : { 25 | "__type" : "email", 26 | "emailString" : "" 27 | }, 28 | "editTime" : { 29 | "__type" : "time", 30 | "time" : { 31 | "__type" : "dateAndTime", 32 | "dateAndTimeString" : "2022-08-17T17:57:10.141+02:00" 33 | } 34 | }, 35 | "uid" : { 36 | "__type" : "uid", 37 | "uidString" : "aK+aptOiDQCOo05HDqN/0g==" 38 | }, 39 | "paragraphStyle" : { 40 | "__type" : "textStyle" 41 | }, 42 | "string" : "Scripts from the git belonging to the book by Alexandre Bergel. These scripts are not yet adjusted to GToolkit, originally created in Pharo 9, so you'll probably need to understand a little bit about programming to use them. " 43 | }, 44 | { 45 | "__type" : "pharoSnippet", 46 | "children" : { 47 | "__type" : "snippets", 48 | "items" : [ ] 49 | }, 50 | "createEmail" : { 51 | "__type" : "email", 52 | "emailString" : "" 53 | }, 54 | "createTime" : { 55 | "__type" : "time", 56 | "time" : { 57 | "__type" : "dateAndTime", 58 | "dateAndTimeString" : "2022-08-17T17:59:22.82+02:00" 59 | } 60 | }, 61 | "editEmail" : { 62 | "__type" : "email", 63 | "emailString" : "" 64 | }, 65 | "editTime" : { 66 | "__type" : "time", 67 | "time" : { 68 | "__type" : "dateAndTime", 69 | "dateAndTimeString" : "2022-08-17T17:59:24.582+02:00" 70 | } 71 | }, 72 | "uid" : { 73 | "__type" : "uid", 74 | "uidString" : "oI12r9OiDQCPZENRDqN/0g==" 75 | }, 76 | "code" : "\"These slides contain all the example scripts for a chapter from the book\"\r(GtLiveShow create: SlidesForScripts13Robottxt new) makeArrowsVisible" 77 | } 78 | ] 79 | }, 80 | "createEmail" : { 81 | "__type" : "email", 82 | "emailString" : "" 83 | }, 84 | "createTime" : { 85 | "__type" : "time", 86 | "time" : { 87 | "__type" : "dateAndTime", 88 | "dateAndTimeString" : "2022-08-17T17:56:54.127+02:00" 89 | } 90 | }, 91 | "editEmail" : { 92 | "__type" : "email", 93 | "emailString" : "" 94 | }, 95 | "editTime" : { 96 | "__type" : "time", 97 | "time" : { 98 | "__type" : "dateAndTime", 99 | "dateAndTimeString" : "2022-08-17T17:56:54.127+02:00" 100 | } 101 | }, 102 | "pageType" : { 103 | "__type" : "namedPage", 104 | "title" : "Maze Robots" 105 | }, 106 | "uid" : { 107 | "__type" : "uuid", 108 | "uuid" : "b0a999a6-d3a2-0d00-8ea2-27450ea37fd2" 109 | } 110 | } -------------------------------------------------------------------------------- /lepiter/cgms9f2fc3o193m0mu3uzdolk.lepiter: -------------------------------------------------------------------------------- 1 | { 2 | "__schema" : "4.1", 3 | "__type" : "page", 4 | "children" : { 5 | "__type" : "snippets", 6 | "items" : [ 7 | { 8 | "__type" : "textSnippet", 9 | "children" : { 10 | "__type" : "snippets", 11 | "items" : [ ] 12 | }, 13 | "createEmail" : { 14 | "__type" : "email", 15 | "emailString" : "" 16 | }, 17 | "createTime" : { 18 | "__type" : "time", 19 | "time" : { 20 | "__type" : "dateAndTime", 21 | "dateAndTimeString" : "2022-08-17T17:55:01.174+02:00" 22 | } 23 | }, 24 | "editEmail" : { 25 | "__type" : "email", 26 | "emailString" : "" 27 | }, 28 | "editTime" : { 29 | "__type" : "time", 30 | "time" : { 31 | "__type" : "dateAndTime", 32 | "dateAndTimeString" : "2022-08-17T17:55:01.174+02:00" 33 | } 34 | }, 35 | "uid" : { 36 | "__type" : "uid", 37 | "uidString" : "MOWpmdOiDQCOcMuKDqN/0g==" 38 | }, 39 | "paragraphStyle" : { 40 | "__type" : "textStyle" 41 | }, 42 | "string" : "Scripts from the git belonging to the book by Alexandre Bergel. These scripts are not yet adjusted to GToolkit, originally created in Pharo 9, so you'll probably need to understand a little bit about programming to use them. " 43 | }, 44 | { 45 | "__type" : "pharoSnippet", 46 | "children" : { 47 | "__type" : "snippets", 48 | "items" : [ ] 49 | }, 50 | "createEmail" : { 51 | "__type" : "email", 52 | "emailString" : "" 53 | }, 54 | "createTime" : { 55 | "__type" : "time", 56 | "time" : { 57 | "__type" : "dateAndTime", 58 | "dateAndTimeString" : "2022-08-17T17:55:14.357+02:00" 59 | } 60 | }, 61 | "editEmail" : { 62 | "__type" : "email", 63 | "emailString" : "" 64 | }, 65 | "editTime" : { 66 | "__type" : "time", 67 | "time" : { 68 | "__type" : "dateAndTime", 69 | "dateAndTimeString" : "2022-08-17T17:55:30.888+02:00" 70 | } 71 | }, 72 | "uid" : { 73 | "__type" : "uid", 74 | "uidString" : "CE+noNOiDQCOdPXTDqN/0g==" 75 | }, 76 | "code" : "(GtLiveShow create: SlidesForScripts12TravelingSalesmanProblemtxt new) makeArrowsVisible\"These slides contain all the example scripts for a chapter from the book\"\r" 77 | } 78 | ] 79 | }, 80 | "createEmail" : { 81 | "__type" : "email", 82 | "emailString" : "" 83 | }, 84 | "createTime" : { 85 | "__type" : "time", 86 | "time" : { 87 | "__type" : "dateAndTime", 88 | "dateAndTimeString" : "2022-08-17T17:53:17.006+02:00" 89 | } 90 | }, 91 | "editEmail" : { 92 | "__type" : "email", 93 | "emailString" : "" 94 | }, 95 | "editTime" : { 96 | "__type" : "time", 97 | "time" : { 98 | "__type" : "dateAndTime", 99 | "dateAndTimeString" : "2022-08-17T17:53:17.006+02:00" 100 | } 101 | }, 102 | "pageType" : { 103 | "__type" : "namedPage", 104 | "title" : "Traveling Salesman" 105 | }, 106 | "uid" : { 107 | "__type" : "uuid", 108 | "uuid" : "c8a8a899-d3a2-0d00-8e6f-85f10ea37fd2" 109 | } 110 | } -------------------------------------------------------------------------------- /lepiter/lepiter.properties: -------------------------------------------------------------------------------- 1 | { 2 | "uuid" : "11909a55-ec8a-0d00-9bb8-cc880cd825da", 3 | "tableOfContents" : "ek8coyhdegg5vge8pyevbbba1", 4 | "schema" : "4.1" 5 | } -------------------------------------------------------------------------------- /markdown/infoAboutWorkshop.md: -------------------------------------------------------------------------------- 1 | # Extra info about 'Intro Neural Networks Part 1' 2 | 3 | 4 | + No prior programming background required, although we will probably see some Objects like Neurons and NeuralNetworks sending messages to each other... but that's mainly to dive into how a neural network works. You will be surprised (well, I was) how simple the principles behind a Neuron are. (yes, a Network is more difficult, but ) 5 | 6 | + We will also avoid mathematics, although some simple calculation will be unavoidable. 7 | 8 | + No background in biology required, although that is the source of a lot of AI ideas. 9 | 10 | + To get a glimpse you could take a short look at: https://github.com/coentjo/agile-ai-in-pharo (scroll down to the readme for some screenshots), but it is not necessary to join the session. 11 | 12 | + How can (in essence) a 'programmed system' get smarter without 're-programming'? How does 'learning' work? How does 'training' work? 13 | 14 | + Bring on your laptop as well as your questions: I hope to make it interactive! (but also please help me in making it interesting for the whole group, as diverse as it is. 15 | 16 | + I am not sure how far we will get in the first session, because I hope we will have some discussions on the fly. In the end, or afterward, we can decide which direction to go in the second session! 17 | 18 | + We will be guided by Chepetto. 19 | -------------------------------------------------------------------------------- /markdown/mentimeter.md: -------------------------------------------------------------------------------- 1 | In March 2023 I used Mentimeter during the workshop: 2 | 3 | Fontys teachers can use this link: 4 | https://www.mentimeter.com/app/auth/saml/fontys 5 | -------------------------------------------------------------------------------- /scripts/03-chapter3.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | g := RTGrapher new. d := RTData new. d connectColor: Color blue. d noDot. d points: (-7.0 to: 7.0 by: 0.01). d x: #yourself. d y: [ :x | x > 0 ifTrue: [ 1 ] ifFalse: [ 0 ] ]. g add: d. g 4 | 5 | ----------------------------- 6 | g := RTGrapher new. d := RTData new. d connectColor: Color blue. d noDot. d points: (-7.0 to: 7.0 by: 0.01). d x: #yourself. d y: [ :x | 1 / (1 + (x negated exp)) ]. g add: d. g 7 | 8 | ----------------------------- 9 | learningCurveNeuron := OrderedCollection new. 0 to: 1000 do: [ :nbOfTrained | p := Neuron new. p weights: #(-1 -1). p bias: 2. nbOfTrained timesRepeat: [ p train: #(0 0) desiredOutput: 0. p train: #(0 1) desiredOutput: 0. p train: #(1 0) desiredOutput: 0. p train: #(1 1) desiredOutput: 1 ]. res := ((p feed: #(0 0)) - 0) abs + ((p feed: #(0 1)) - 0) abs + ((p feed: #(1 0)) - 0) abs + ((p feed: #(1 1)) - 1) abs. learningCurveNeuron add: res / 4. ]. learningCurvePerceptron := OrderedCollection new. 0 to: 1000 do: [ :nbOfTrained | p := Neuron new. p step. p weights: #(-1 -1). p bias: 2. nbOfTrained timesRepeat: [ p train: #(0 0) desiredOutput: 0. p train: #(0 1) desiredOutput: 0. p train: #(1 0) desiredOutput: 0. p train: #(1 1) desiredOutput: 1 ]. res := ((p feed: #(0 0)) - 0) abs + ((p feed: #(0 1)) - 0) abs + ((p feed: #(1 0)) - 0) abs + ((p feed: #(1 1)) - 1) abs. learningCurvePerceptron add: res / 4. ]. g := RTGrapher new. d := RTData new. d label: 'Sigmoid neuron'. d noDot. d connectColor: Color blue. d points: learningCurveNeuron. d y: #yourself. g add: d. d := RTData new. d label: 'Perceptron'. d noDot. d connectColor: Color green. d points: learningCurvePerceptron. d y: #yourself. g add: d. g axisY title: 'Error'. g axisX noDecimal; title: 'Epoch'. g legend addText: 'Perceptron vs Sigmoid neuron'. g 10 | -------------------------------------------------------------------------------- /scripts/07-MatrixLibrary.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | m := MMatrix newFromArrays: #(#(1 2 3) #(4 5 6)). m + m 4 | 5 | ----------------------------- 6 | n := 8. "Number of examples" din := 10. "Number of input values" h := 20. "Size of the hidden layer" dout := 5. "Number of output values" r := Random seed: 42. x := (MMatrix newRows: n columns: din) random: r. y := (MMatrix newRows: n columns: dout) random: r. w1 := (MMatrix newRows: din columns: h) random: r. w2 := (MMatrix newRows: h columns: dout) random: r. learningRate := 1e-6. losses := OrderedCollection new. 1500 timesRepeat: [ hh := x +* w1. hrelu := hh collect: [ :v | v max: 0 ]. ypred := hrelu +* w2. "Compute and print loss" loss := ((ypred - y) collect: [:vv | vv * vv ]) sum. losses add: loss. "Backprop to compute gradients of w2 and w2 with respect to loss" gradYPred := (ypred - y) * 2.0. gradW2 := hrelu transposed +* gradYPred. gradHRelu := gradYPred +* w2 transposed. gradH := gradHRelu collect: [ :v | v max: 0 ]. gradW1 := x transposed +* gradH. w1 := w1 - (gradW1 * learningRate). w2 := w2 - (gradW2 * learningRate) ]. g := RTGrapher new. d := RTData new. d noDot; connectColor: Color blue. d points: losses. d y: #yourself. g add: d. g axisX title: 'Epoch'. g axisY title: 'Error'. g 7 | -------------------------------------------------------------------------------- /scripts/08-MatrixNN.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | xor := #(#(0 0 0) #(0 1 1) #(1 0 1) #(1 1 0)). n := NMNetwork new. n configure: 2 hidden: 3 nbOfOutputs: 2. n train: xor nbEpochs: 5000. n predict: (MMatrix newFromVector: #(1 0)). 4 | 5 | ----------------------------- 6 | "The execution of this script initializes the variable irisData. This variable is used in the subsequent scripts of this chapter" irisCSV := (ZnEasy get: 'https://agileartificialintelligence.github.io/Datasets/iris.csv') contents. lines := irisCSV lines. lines := lines allButFirst. tLines := lines collect: [ :l | | ss | ss := l substrings: ','. (ss allButLast collect: [ :w | w asNumber ]), (Array with: ss last) ]. irisData := tLines collect: [ :row | |l| row last = 'setosa' ifTrue: [ l := #( 0 ) ]. row last = 'versicolor' ifTrue: [ l := #( 1 ) ]. row last = 'virginica' ifTrue: [ l := #( 2 ) ]. row allButLast, l ]. irisData. n := NMNetwork new. n configure: 4 hidden: 6 nbOfOutputs: 3. n train: irisData nbEpochs: 3000. n 7 | -------------------------------------------------------------------------------- /scripts/10-GeneticAlgorithm.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | [ :x :y | x + y ] cull: 10 cull: 20 cull: 30. "=> 20" [ :x :y :z | x + y + z] cull: 10 cull: 20 cull: 30. "=> 60" [ 42 ] cull: 10 cull: 20 cull: 30. "=> 42" 4 | 5 | ----------------------------- 6 | inds := GAIndividual create: 1000 individualsAndInitialize: 3 genesWith: [ :r | ($a to: $z) atRandom: r ]. fitnessBlock := [ :genes | (genes with: 'cat' asArray collect: [ :a :b | (a == b) ifTrue: [ 1 ] ifFalse: [ 0 ] ]) sum ]. inds do: [ :i | i computeFitnessUsing: fitnessBlock ]. 7 | 8 | ----------------------------- 9 | inds := GAIndividual create: 1000 individualsAndInitialize: 3 genesWith: [ :r | ($a to: $z) atRandom: r ]. fitnessBlock := [ :genes | (genes with: 'cat' asArray collect: [ :a :b | (a == b) ifTrue: [ 1 ] ifFalse: [ 0 ] ]) sum ]. inds do: [ :i | i computeFitnessUsing: fitnessBlock ]. ... data := ((inds collect: #fitness) groupedBy: #yourself) associations collect: [ : as | as key -> as value size ] . g := RTGrapher new. d := RTData new. d points: data. d barChartWithBarTitle: #key. d y: [ :as | as value ]. d yLog. g add: d. g axisY noDecimal. g axisX noTick. g 10 | 11 | ----------------------------- 12 | inds := GAIndividual create: 100000 individualsAndInitialize: 3 genesWith: [ :r | ($a to: $z) atRandom: r ]. fitnessBlock := [ :genes | (genes with: 'cat' asArray collect: [ :a :b | (a == b) ifTrue: [ 1 ] ifFalse: [ 0 ] ]) sum ]. inds do: [ :i | i computeFitnessUsing: fitnessBlock ]. data := ((inds collect: #fitness) groupedBy: #yourself) associations collect: [ : as | as key -> as value size ] . g := RTGrapher new. d := RTData new. d points: data. d barChartWithBarTitle: #key. d y: [ :as | as value ]. d yLog. g add: d. g axisY noDecimal. g axisX noTick. g 13 | 14 | ----------------------------- 15 | g := GAEngine new. g populationSize: 1000. g numberOfGenes: 4. g createGeneBlock: [ :rand :index :ind | ($a to: $z) atRandom: rand ]. g fitnessBlock: [ :genes | (#($g $a $t $o) with: genes collect: [ :a :b | a = b ifTrue: [ 1 ] ifFalse: [ 0 ] ]) sum ]. g run. 16 | -------------------------------------------------------------------------------- /scripts/13-Robot.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | "We build a map with 80 wall blocks" map := GARobotMap new fillWithWalls: 80. "We build the robot" robot := GARobot new. "Make the robot lives in the map" robot map: map. g := GAEngine new. g endIfNoImprovementFor: 5. g numberOfGenes: 100. g populationSize: 250. "A gene value is a cardinal direction" g createGeneBlock: [ :rand :index :ind | #($N $S $W $E) atRandom: rand ]. "We want to minimize the distance between the robot and the exit" g minimizeComparator. g fitnessBlock: [ :genes | robot followOrders: genes. robot position dist: map exitPosition ]. g run. 4 | 5 | ----------------------------- 6 | "We build a map with 80 wall blocks" map := GARobotMap new fillWithWalls: 80. "We build the robot" robot := GARobot new. "Make the robot lives in the map" robot map: map. g := GAEngine new. g endIfNoImprovementFor: 5. g numberOfGenes: 100. g populationSize: 250. "A gene value is a cardinal direction" g createGeneBlock: [ :rand :index :ind | #($N $S $W $E) atRandom: rand ]. "We want to minimize the distance between the robot and the exit" g minimizeComparator. g fitnessBlock: [ :genes | robot followOrders: genes. robot position dist: map exitPosition ]. g run. ... map drawRobotPath: (robot followOrders: g result). map open 7 | 8 | ----------------------------- 9 | map := GARobotMap new fillWithWalls: 80. robot := GARobot new. robot map: map. g := GAEngine new. g endIfNoImprovementFor: 5. g numberOfGenes: 100. g populationSize: 250. g createGeneBlock: [ :rand :index :ind | #($N $S $W $E) atRandom: rand ]. g minimizeComparator. g fitnessBlock: [ :genes | | path penalty | path := robot followOrders: genes. penalty := path size / 2. (robot position dist: map exitPosition) + penalty ]. g run. map drawRobotPath: (robot followOrders: g result). map open 10 | -------------------------------------------------------------------------------- /scripts/14-Zoomorphic.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | creature := CCreature new configureBall: 10. c := CWorld new. c addCreature: creature. c open 4 | 5 | ----------------------------- 6 | redCreature := CCreature new configureBall: 7. blueCreature := CCreature new color: Color blue; configureBall: 10. yellowCreature := CCreature new color: Color yellow; configureBall: 15. c := CWorld new. c addCreature: redCreature. c addCreature: blueCreature. c addCreature: yellowCreature. c open. blueCreature translateTo: 100 @ -50. yellowCreature translateTo: 200 @ -50. 7 | -------------------------------------------------------------------------------- /scripts/15-ZoomorphicSimulation.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | creature := CCreature new configureBall: 10. creature materialize: #(24 34 0.46040109215788594 216 145 75 50 0.522318108469396 127 33 33 39 0.9105445367193523 70 93 30 88 0.5458242390378492 55 104 32 78 0.9326984656055917 36 74 20 38 0.23007194683890417 169 77 25 31 0.6407352956527543 219 147 28 14 0.5132012814205146 70 67 41 32 0.4101663086936652 116 21 30 53 0.4132064962215752 140 69 26 16 0.67239310366213 174 81 90 40 0.9493843137376868 77 82 90 24 0.9472498080773512 72 76 77 15 0.8207815849644977 51 46 63 21 0.23135899086546108 29 170 33 24 0.8508932494190025 70 94 34 32 0.85425589900662 192 99 83 84 0.8219266167338596 153 144 74 57 0.18008196523882541 38 136 76 82 0.4098378945513805 108 122 73 25 0.13200707016606214 72 102 11 24 0.525760215705149 60 33 34 53 0.47843877270279395 207 167 53 53 0.06064744597796698 47 203 90 90 0.3480303188869871 101 204 77 42 0.05166656036007524 143 155 67 89 0.5535930274164271 146 23 35 39 0.8390450097196945 136 143 78 87 0.955747404799679 153 71 15 84 0.9765097738460218 34 26 36 14 0.13894161191253998 78 51 38 41 0.1316714140594338 114 205 74 74 0.7760572821116342 191 32 67 61 0.08824125377379416 219 149 18 70 0.1469941007052521 169 175 39 43 0.2866080141424239 133 71 90 42 0.8735930218098653 90 85 53 21 0.18471918099313936 39 146 60 44 0.3135163908747567 120 38 57 43 0.32777994628892276 187 148 34 23 0.3158802803540045 35 102 75 42 0.1347404502354285 109 125 28 76 0.12238997760805766 64 23 68 70 0.9608936917180632 179 175 28 24 0.06067319378753807 116 196 ). c := CWorld new. c addCreature: creature. c open 4 | -------------------------------------------------------------------------------- /scripts/16-Neuroevolution.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | data := { {0 . 0 . 0} . {0 . 1 . 1} . {1 . 0 . 1} . {1 . 1 . 0} }. n := NNetwork new. n configure: 2 hidden: 3 nbOfOutputs: 2. g := GAEngine new. g populationSize: 500. g mutationRate: 0.01. g endForMaxNumberOfGeneration: 30. g crossoverOperator: (GAConstrainedCrossoverOperation new possibleCutpoints: n getPossibleCutpoints). g numberOfGenes: n numberOfParameters. g createGeneBlock: [ :rand :index :ind | rand next * 10 - 5 ]. g fitnessBlock: [ :genes | | r | n setWeightsAndBias: genes. r := (data collect: [ :row | (n predict: row allButLast) = row last ]) select: #yourself. (r size / 4) round: 4. ]. g run. 4 | 5 | ----------------------------- 6 | data := { { 0 . 0 . 0 . 0 } . { 0 . 0 . 1 . 1 } . { 0 . 1 . 0 . 2 } . { 0 . 1 . 1 . 3 } . { 1 . 0 . 0 . 4 } . { 1 . 0 . 1 . 5 } . { 1 . 1 . 0 . 6 } . { 1 . 1 . 1 . 7 } }. n := NNetwork new. n configure: 3 hidden: 5 nbOfOutputs: 8. g := GAEngine new. g populationSize: 500. g endForMaxNumberOfGeneration: 100. g crossoverOperator: (GAConstrainedCrossoverOperation new possibleCutpoints: n getPossibleCutpoints). g numberOfGenes: n numberOfParameters. g createGeneBlock: [ :rand :index :ind | rand next * 10 - 5 ]. g fitnessBlock: [ :genes | | r | n setWeightsAndBias: genes. r := (data collect: [ :row | (n predict: row allButLast) = row last ]) select: #yourself. (r size / data size) round: 4. ]. g run. 7 | 8 | ----------------------------- 9 | irisCSV := (ZnEasy get: 'https://agileartificialintelligence.github.io/Datasets/iris.csv') contents. lines := irisCSV lines allButFirst collect: [ :l | | ss | ss := l substrings: ','. (ss allButLast collect: [ :w | w asNumber ]), { ss last } ]. irisData := lines collect: [ :row | | l | row last = 'setosa' ifTrue: [ l := #( 0 ) ]. row last = 'versicolor' ifTrue: [ l := #( 1 ) ]. row last = 'virginica' ifTrue: [ l := #( 2 ) ]. row allButLast, l ]. "The variable irisData contains the Iris dataset" n := NNetwork new. n configure: 4 hidden: 6 nbOfOutputs: 3. g := GAEngine new. g populationSize: 500. g endForMaxNumberOfGeneration: 30. g crossoverOperator: (GAConstrainedCrossoverOperation new possibleCutpoints: n getPossibleCutpoints). g numberOfGenes: n numberOfParameters. g createGeneBlock: [ :rand :index :ind | rand next * 10 - 5 ]. g fitnessBlock: [ :genes | | r | n setWeightsAndBias: genes. r := (irisData collect: [ :row | (n predict: row allButLast) = row last ]) select: #yourself. (r size / irisData size) asFloat round: 4 ]. g run. 10 | -------------------------------------------------------------------------------- /scripts/17-NEAT.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | dataset := #( #(0 0 0) #(0 1 1) #(1 0 1) #(1 1 0) ). neat := NEAT new. neat numberOfInputs: 2. neat numberOfOutputs: 1. neat fitness: [ :ind | | score | score := 0. dataset do: [ :tuple | diff := (ind evaluate: tuple allButLast) first - tuple last. score := score + (diff * diff) ]. (score / -4) asFloat ]. neat numberOfGenerations: 180. neat run. 4 | 5 | ----------------------------- 6 | "We prepare the data" irisCSV := (ZnEasy get: 'https://agileartificialintelligence.github.io/Datasets/iris.csv') contents. lines := irisCSV lines. lines := lines allButFirst. tLines := lines collect: [ :l | | ss | ss := l substrings: ','. (ss allButLast collect: [ :w | w asNumber ]), (Array with: ss last) ]. irisData := tLines collect: [ :row | | l | row last = 'setosa' ifTrue: [ l := #( 0 ) ]. row last = 'versicolor' ifTrue: [ l := #( 1 ) ]. row last = 'virginica' ifTrue: [ l := #( 2 ) ]. row allButLast, l ]. "We run the NEAT algorithm" neat := NEAT new. neat numberOfInputs: 4. neat numberOfOutputs: 3. neat fitness: [ :ind | | score | score := 0. irisData do: [ :tuple | diff := (ind predict: tuple allButLast) - tuple last. score := score + (diff * diff) ]. (score / -4) asFloat ]. neat numberOfGenerations: 180. neat run. 7 | -------------------------------------------------------------------------------- /scripts/18-MarioGame.txt: -------------------------------------------------------------------------------- 1 | 2 | ----------------------------- 3 | MNWorld new open 4 | 5 | ----------------------------- 6 | MNWorld new seed: 7; open 7 | 8 | ----------------------------- 9 | MNWorld new showCompleteMap 10 | 11 | ----------------------------- 12 | MNWorld new seed: 7; showCompleteMap 13 | 14 | ----------------------------- 15 | neat := NEAT new. neat numberOfInputs: 121. neat numberOfOutputs: 3. neat populationSize: 200. neat fitness: [ :ind | w := MNWorld new. w mario: (MNAIMario new network: ind). 450 timesRepeat: [ w beat. ]. w mario position x ]. neat numberOfGenerations: 160. neat run. 16 | 17 | ----------------------------- 18 | neat := NEAT new. neat numberOfInputs: 121. neat numberOfOutputs: 3. neat populationSize: 200. neat fitness: [ :ind | w := MNWorld new. w mario: (MNAIMario new network: ind). 450 timesRepeat: [ w beat. ]. w mario position x ]. neat numberOfGenerations: 160. neat run. ... w := MNWorld new. w mario: (MNAIMario new network: neat result). w open 19 | 20 | ----------------------------- 21 | MNWorld new open 22 | 23 | ----------------------------- 24 | MNWorld new seed: 7; open 25 | 26 | ----------------------------- 27 | MNWorld new showCompleteMap 28 | 29 | ----------------------------- 30 | MNWorld new seed: 7; showCompleteMap 31 | 32 | ----------------------------- 33 | neat := NEAT new. neat numberOfInputs: 121. neat numberOfOutputs: 3. neat populationSize: 200. neat fitness: [ :ind | w := MNWorld new. w mario: (MNAIMario new network: ind). 450 timesRepeat: [ w beat. ]. w mario position x ]. neat numberOfGenerations: 160. neat run. 34 | 35 | ----------------------------- 36 | neat := NEAT new. neat numberOfInputs: 121. neat numberOfOutputs: 3. neat populationSize: 200. neat fitness: [ :ind | w := MNWorld new. w mario: (MNAIMario new network: ind). 450 timesRepeat: [ w beat. ]. w mario position x ]. neat numberOfGenerations: 160. neat run. ... w := MNWorld new. w mario: (MNAIMario new network: neat result). w open 37 | -------------------------------------------------------------------------------- /slides/2021-AI-General.001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.001.png -------------------------------------------------------------------------------- /slides/2021-AI-General.002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.002.png -------------------------------------------------------------------------------- /slides/2021-AI-General.003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.003.png -------------------------------------------------------------------------------- /slides/2021-AI-General.004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.004.png -------------------------------------------------------------------------------- /slides/2021-AI-General.005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.005.png -------------------------------------------------------------------------------- /slides/2021-AI-General.006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.006.png -------------------------------------------------------------------------------- /slides/2021-AI-General.007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.007.png -------------------------------------------------------------------------------- /slides/2021-AI-General.008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.008.png -------------------------------------------------------------------------------- /slides/2021-AI-General.009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.009.png -------------------------------------------------------------------------------- /slides/2021-AI-General.010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.010.png -------------------------------------------------------------------------------- /slides/2021-AI-General.011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.011.png -------------------------------------------------------------------------------- /slides/2021-AI-General.012.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.012.png -------------------------------------------------------------------------------- /slides/2021-AI-General.013.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.013.png -------------------------------------------------------------------------------- /slides/2021-AI-General.014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.014.png -------------------------------------------------------------------------------- /slides/2021-AI-General.015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.015.png -------------------------------------------------------------------------------- /slides/2021-AI-General.016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.016.png -------------------------------------------------------------------------------- /slides/2021-AI-General.017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.017.png -------------------------------------------------------------------------------- /slides/2021-AI-General.018.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.018.png -------------------------------------------------------------------------------- /slides/2021-AI-General.019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.019.png -------------------------------------------------------------------------------- /slides/2021-AI-General.020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.020.png -------------------------------------------------------------------------------- /slides/2021-AI-General.021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.021.png -------------------------------------------------------------------------------- /slides/2021-AI-General.022.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.022.png -------------------------------------------------------------------------------- /slides/2021-AI-General.023.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.023.png -------------------------------------------------------------------------------- /slides/2021-AI-General.024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.024.png -------------------------------------------------------------------------------- /slides/2021-AI-General.025.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.025.png -------------------------------------------------------------------------------- /slides/2021-AI-General.026.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.026.png -------------------------------------------------------------------------------- /slides/2021-AI-General.027.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.027.png -------------------------------------------------------------------------------- /slides/2021-AI-General.028.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.028.png -------------------------------------------------------------------------------- /slides/2021-AI-General.029.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.029.png -------------------------------------------------------------------------------- /slides/2021-AI-General.030.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.030.png -------------------------------------------------------------------------------- /slides/2021-AI-General.031.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.031.png -------------------------------------------------------------------------------- /slides/2021-AI-General.032.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.032.png -------------------------------------------------------------------------------- /slides/2021-AI-General.033.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.033.png -------------------------------------------------------------------------------- /slides/2021-AI-General.034.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.034.png -------------------------------------------------------------------------------- /slides/2021-AI-General.035.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.035.png -------------------------------------------------------------------------------- /slides/2021-AI-General.036.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.036.png -------------------------------------------------------------------------------- /slides/2021-AI-General.037.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.037.png -------------------------------------------------------------------------------- /slides/2021-AI-General.038.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.038.png -------------------------------------------------------------------------------- /slides/2021-AI-General.039.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.039.png -------------------------------------------------------------------------------- /slides/2021-AI-General.040.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.040.png -------------------------------------------------------------------------------- /slides/2021-AI-General.041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.041.png -------------------------------------------------------------------------------- /slides/2021-AI-General.042.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.042.png -------------------------------------------------------------------------------- /slides/2021-AI-General.043.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.043.png -------------------------------------------------------------------------------- /slides/2021-AI-General.044.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.044.png -------------------------------------------------------------------------------- /slides/2021-AI-General.045.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.045.png -------------------------------------------------------------------------------- /slides/2021-AI-General.046.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.046.png -------------------------------------------------------------------------------- /slides/2021-AI-General.047.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.047.png -------------------------------------------------------------------------------- /slides/2021-AI-General.048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.048.png -------------------------------------------------------------------------------- /slides/2021-AI-General.049.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.049.png -------------------------------------------------------------------------------- /slides/2021-AI-General.050.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.050.png -------------------------------------------------------------------------------- /slides/2021-AI-General.051.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.051.png -------------------------------------------------------------------------------- /slides/2021-AI-General.052.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.052.png -------------------------------------------------------------------------------- /slides/2021-AI-General.053.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.053.png -------------------------------------------------------------------------------- /slides/2021-AI-General.054.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.054.png -------------------------------------------------------------------------------- /slides/2021-AI-General.055.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.055.png -------------------------------------------------------------------------------- /slides/2021-AI-General.056.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.056.png -------------------------------------------------------------------------------- /slides/2021-AI-General.057.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.057.png -------------------------------------------------------------------------------- /slides/2021-AI-General.058.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.058.png -------------------------------------------------------------------------------- /slides/2021-AI-General.059.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.059.png -------------------------------------------------------------------------------- /slides/2021-AI-General.060.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.060.png -------------------------------------------------------------------------------- /slides/2021-AI-General.061.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.061.png -------------------------------------------------------------------------------- /slides/2021-AI-General.062.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.062.png -------------------------------------------------------------------------------- /slides/2021-AI-General.063.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.063.png -------------------------------------------------------------------------------- /slides/2021-AI-General.064.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.064.png -------------------------------------------------------------------------------- /slides/2021-AI-General.065.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.065.png -------------------------------------------------------------------------------- /slides/2021-AI-General.066.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.066.png -------------------------------------------------------------------------------- /slides/2021-AI-General.067.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.067.png -------------------------------------------------------------------------------- /slides/2021-AI-General.068.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.068.png -------------------------------------------------------------------------------- /slides/2021-AI-General.069.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.069.png -------------------------------------------------------------------------------- /slides/2021-AI-General.070.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.070.png -------------------------------------------------------------------------------- /slides/2021-AI-General.071.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.071.png -------------------------------------------------------------------------------- /slides/2021-AI-General.072.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.072.png -------------------------------------------------------------------------------- /slides/2021-AI-General.073.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.073.png -------------------------------------------------------------------------------- /slides/2021-AI-General.074.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.074.png -------------------------------------------------------------------------------- /slides/2021-AI-General.075.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.075.png -------------------------------------------------------------------------------- /slides/2021-AI-General.076.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.076.png -------------------------------------------------------------------------------- /slides/2021-AI-General.077.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.077.png -------------------------------------------------------------------------------- /slides/2021-AI-General.078.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.078.png -------------------------------------------------------------------------------- /slides/2021-AI-General.079.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.079.png -------------------------------------------------------------------------------- /slides/2021-AI-General.080.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.080.png -------------------------------------------------------------------------------- /slides/2021-AI-General.081.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.081.png -------------------------------------------------------------------------------- /slides/2021-AI-General.082.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.082.png -------------------------------------------------------------------------------- /slides/2021-AI-General.083.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.083.png -------------------------------------------------------------------------------- /slides/2021-AI-General.084.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.084.png -------------------------------------------------------------------------------- /slides/2021-AI-General.085.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.085.png -------------------------------------------------------------------------------- /slides/2021-AI-General.086.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.086.png -------------------------------------------------------------------------------- /slides/2021-AI-General.087.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.087.png -------------------------------------------------------------------------------- /slides/2021-AI-General.088.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.088.png -------------------------------------------------------------------------------- /slides/2021-AI-General.089.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.089.png -------------------------------------------------------------------------------- /slides/2021-AI-General.090.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.090.png -------------------------------------------------------------------------------- /slides/2021-AI-General.091.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.091.png -------------------------------------------------------------------------------- /slides/2021-AI-General.092.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.092.png -------------------------------------------------------------------------------- /slides/2021-AI-General.093.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.093.png -------------------------------------------------------------------------------- /slides/2021-AI-General.094.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.094.png -------------------------------------------------------------------------------- /slides/2021-AI-General.095.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.095.png -------------------------------------------------------------------------------- /slides/2021-AI-General.096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.096.png -------------------------------------------------------------------------------- /slides/2021-AI-General.097.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.097.png -------------------------------------------------------------------------------- /slides/2021-AI-General.098.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.098.png -------------------------------------------------------------------------------- /slides/2021-AI-General.099.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.099.png -------------------------------------------------------------------------------- /slides/2021-AI-General.100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/2021-AI-General.100.png -------------------------------------------------------------------------------- /slides/NeuralNetworks.Mobile-apps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coentjo/agile-ai-in-pharo/476a0e981fa836372937858ee5369a051434628f/slides/NeuralNetworks.Mobile-apps.png -------------------------------------------------------------------------------- /src/.properties: -------------------------------------------------------------------------------- 1 | { 2 | #format : #tonel 3 | } -------------------------------------------------------------------------------- /src/BaselineOfAgileArtificialIntelligence/BaselineOfAgileArtificialIntelligence.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #BaselineOfAgileArtificialIntelligence, 3 | #superclass : #BaselineOf, 4 | #category : #BaselineOfAgileArtificialIntelligence 5 | } 6 | 7 | { #category : #accessing } 8 | BaselineOfAgileArtificialIntelligence class >> loadLepiter [ 9 | | currentProperties | 10 | currentProperties := LeDatabasesRegistry defaultLogicalDatabase properties. 11 | currentProperties 12 | addRegisteredDirectory: FileLocator imageDirectory 13 | / 'pharo-local' 14 | / 'iceberg' 15 | / 'coentjo' 16 | / 'agile-ai-in-pharo' 17 | / 'lepiter'. 18 | LeDatabasesRegistry default defaultLogicalDatabase reload. 19 | 20 | 21 | ] 22 | 23 | { #category : #baselines } 24 | BaselineOfAgileArtificialIntelligence >> baseline: spec [ 25 | 26 | spec 27 | for: #common 28 | do: [ 29 | "spec baseline: 'Roassal2' with: [ spec repository: 'github://ObjectProfile/Roassal2/src' ]." 30 | 31 | spec package: 'NeuralNetwork' with: [ "spec requires: 'Roassal2' " ]. 32 | spec package: 'Matrix'. 33 | spec package: 'NeuralNetwork-Matrix' with: [ spec requires: #('Matrix' 'NeuralNetwork') ]. 34 | 35 | spec package: 'GeneticAlgorithm-Core'. 36 | spec package: 'GeneticAlgorithm-Tests' with: [ spec requires: 'GeneticAlgorithm-Core' ]. 37 | spec package: 'Robot' with: [ spec requires: 'GeneticAlgorithm-Core' ]. 38 | spec package: 'Creature' with: [ spec requires: 'GeneticAlgorithm-Core' ]. 39 | 40 | spec package: 'NEAT' with: [ "spec requires: 'Roassal2' " ]. 41 | spec package: 'MiniMario' with: [ spec requires: 'NEAT' ]. 42 | 43 | spec group: 'Core' with: #('NeuralNetwork' 'Matrix' 'NeuralNetwork-Matrix' 'GeneticAlgorithm-Core' 'GeneticAlgorithm-Tests' 'Robot' 'Creature' 'NEAT' 'MiniMario') 44 | ]. 45 | 46 | spec for: #GToolkit do: [ 47 | spec package: 'NeuralNetwork-GToolkit' with: [ spec requires: #(NeuralNetwork) ] ] 48 | ] 49 | 50 | { #category : #accessing } 51 | BaselineOfAgileArtificialIntelligence >> customProjectAttributes [ 52 | ^ self isGTImage 53 | ifFalse: [ #(notGToolkit) ] 54 | ifTrue: [ #(GToolkit) ] 55 | ] 56 | 57 | { #category : #accessing } 58 | BaselineOfAgileArtificialIntelligence >> isGTImage [ 59 | ^ RPackageOrganizer default packageNames anySatisfy: [ :pn | pn beginsWith: 'GToolkit-'] 60 | ] 61 | -------------------------------------------------------------------------------- /src/BaselineOfAgileArtificialIntelligence/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #BaselineOfAgileArtificialIntelligence } 2 | -------------------------------------------------------------------------------- /src/Creature/CConnection.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #CConnection, 3 | #superclass : #CVisualElement, 4 | #instVars : [ 5 | 'node1', 6 | 'node2' 7 | ], 8 | #category : #Creature 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | CConnection >> node1 [ 13 | ^ node1 14 | ] 15 | 16 | { #category : #'as yet unclassified' } 17 | CConnection >> node1: aNode [ 18 | node1 := aNode 19 | ] 20 | 21 | { #category : #'as yet unclassified' } 22 | CConnection >> node2 [ 23 | ^ node2 24 | ] 25 | 26 | { #category : #'as yet unclassified' } 27 | CConnection >> node2: aNode [ 28 | node2 := aNode 29 | ] 30 | -------------------------------------------------------------------------------- /src/Creature/CNode.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #CNode, 3 | #superclass : #CVisualElement, 4 | #instVars : [ 5 | 'speedVector', 6 | 'force', 7 | 'isOnPlatform' 8 | ], 9 | #category : #Creature 10 | } 11 | 12 | { #category : #'as yet unclassified' } 13 | CNode >> addForce: aForceAsPoint [ 14 | "Make the node subject of an external force" 15 | force := force + aForceAsPoint 16 | ] 17 | 18 | { #category : #'as yet unclassified' } 19 | CNode >> beat [ 20 | "Make the node act according to the force and speed applied to the node" 21 | speedVector := (speedVector + self gravityForce + force) * 0.9. 22 | isOnPlatform ifTrue: [ 23 | speedVector := speedVector x * 0.3 @ speedVector y ]. 24 | self translateBy: speedVector 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | CNode >> checkForCollision: platforms [ 29 | "Verify if the node is on a platform. If it is the case, 30 | the variable isOnPlatform is set to true" 31 | isOnPlatform := false. 32 | platforms 33 | do: [ :p | 34 | (p collide: self) 35 | ifTrue: [ 36 | speedVector := speedVector x @ 0. 37 | p adjustNodeIfNecessary: self. 38 | isOnPlatform := true. 39 | ^ self ] ] 40 | ] 41 | 42 | { #category : #'as yet unclassified' } 43 | CNode >> createElement [ 44 | element := RTEllipse new size: 10; 45 | color: Color gray trans; element. 46 | element @ RTDraggable 47 | ] 48 | 49 | { #category : #'as yet unclassified' } 50 | CNode >> gravityForce [ 51 | "A fixed force representing a gravity" 52 | ^ 0 @ 0.3 53 | ] 54 | 55 | { #category : #'as yet unclassified' } 56 | CNode >> initialize [ 57 | super initialize. 58 | isOnPlatform := false. 59 | self resetSpeed. 60 | self resetForce 61 | ] 62 | 63 | { #category : #'as yet unclassified' } 64 | CNode >> isOnPlatform [ 65 | "Is the node on a platform?" 66 | ^ isOnPlatform 67 | ] 68 | 69 | { #category : #'as yet unclassified' } 70 | CNode >> position [ 71 | "Return the position of the node" 72 | ^ element position 73 | ] 74 | 75 | { #category : #'as yet unclassified' } 76 | CNode >> printOn: str [ 77 | super printOn: str. 78 | str nextPut: $<. 79 | str nextPutAll: self hash asString. 80 | str nextPut: $>. 81 | ] 82 | 83 | { #category : #'as yet unclassified' } 84 | CNode >> resetForce [ 85 | "Reset the force exercising on the node" 86 | force := 0 @ 0 87 | ] 88 | 89 | { #category : #'as yet unclassified' } 90 | CNode >> resetSpeed [ 91 | "Make the node stop by canceling its speed" 92 | speedVector := 0 @ 0 93 | ] 94 | 95 | { #category : #'as yet unclassified' } 96 | CNode >> translateBy: aPoint [ 97 | "Translate the node by an incremental point" 98 | element translateBy: aPoint. 99 | ] 100 | 101 | { #category : #'as yet unclassified' } 102 | CNode >> translateTo: aPoint [ 103 | "Translate the node to a new position" 104 | element translateTo: aPoint. 105 | ] 106 | -------------------------------------------------------------------------------- /src/Creature/CPlatform.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #CPlatform, 3 | #superclass : #CVisualElement, 4 | #instVars : [ 5 | 'width', 6 | 'height' 7 | ], 8 | #category : #Creature 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | CPlatform >> adjustNodeIfNecessary: node [ 13 | "Answer whether the platform collide the node" 14 | | bottomNode topPlatform | 15 | bottomNode := node element encompassingRectangle bottomCenter y. 16 | topPlatform := self element encompassingRectangle topCenter y. 17 | 18 | topPlatform < bottomNode 19 | ifTrue: [ node translateBy: 0 @ (topPlatform - bottomNode) ] 20 | ] 21 | 22 | { #category : #'as yet unclassified' } 23 | CPlatform >> collide: node [ 24 | "Answer whether the platform collide with the node argument" 25 | ^ node element encompassingRectangle intersects: self element encompassingRectangle 26 | ] 27 | 28 | { #category : #'as yet unclassified' } 29 | CPlatform >> createElement [ 30 | "Create the visual representation of a platform" 31 | element ifNotNil: [ "already created" ^ self ]. 32 | element := RTBox new width: width; height: height; color: Color gray; element. 33 | ] 34 | 35 | { #category : #'as yet unclassified' } 36 | CPlatform >> height: aHeightAsNumber [ 37 | "Set the height of the platform" 38 | height := aHeightAsNumber 39 | 40 | ] 41 | 42 | { #category : #'as yet unclassified' } 43 | CPlatform >> initialize [ 44 | super initialize. 45 | self width: 100. 46 | self height: 10 47 | ] 48 | 49 | { #category : #'as yet unclassified' } 50 | CPlatform >> translateTo: aPosition [ 51 | "Translate the platform to a particular position" 52 | self createElement. 53 | element translateTo: aPosition 54 | ] 55 | 56 | { #category : #'as yet unclassified' } 57 | CPlatform >> width: aWidthAsNumber [ 58 | "Set the width of the platform" 59 | width := aWidthAsNumber 60 | ] 61 | -------------------------------------------------------------------------------- /src/Creature/CVisualElement.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #CVisualElement, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'element' 6 | ], 7 | #category : #Creature 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | CVisualElement >> createElement [ 12 | "Should be overridden in subclasses. 13 | The method initializes the element variable" 14 | self subclassResponsibility 15 | ] 16 | 17 | { #category : #'as yet unclassified' } 18 | CVisualElement >> element [ 19 | "Return the Roassal element" 20 | ^ element 21 | ] 22 | -------------------------------------------------------------------------------- /src/Creature/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #Creature } 2 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAAbstractCrossoverOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAAbstractCrossoverOperation, 3 | #superclass : #GAOperation, 4 | #category : #'GeneticAlgorithm-Core' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | GAAbstractCrossoverOperation >> crossover: partnerA with: partnerB [ 9 | "Return a new child, which is the result of mixing myself with the argument" 10 | ^ self crossover: partnerA with: partnerB midpoint: (self pickCutPointFor: partnerA) 11 | ] 12 | 13 | { #category : #'as yet unclassified' } 14 | GAAbstractCrossoverOperation >> crossover: partnerA with: partnerB midpoint: midpoint [ 15 | "Return a new child, which is the result of mixing myself with the argument" 16 | 17 | | child crossOverGenes | 18 | child := GAIndividual new. 19 | child random: random. 20 | crossOverGenes := (partnerA genes first: midpoint) 21 | , (partnerB genes allButFirst: midpoint). 22 | child genes: crossOverGenes. 23 | ^ child 24 | ] 25 | 26 | { #category : #'as yet unclassified' } 27 | GAAbstractCrossoverOperation >> pickCutPointFor: anIndividual [ 28 | "Need to be overridden in subclasses" 29 | self subclassResponsibility 30 | ] 31 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAAbstractMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAAbstractMutationOperation, 3 | #superclass : #GAOperation, 4 | #instVars : [ 5 | 'mutationRate' 6 | ], 7 | #category : #'GeneticAlgorithm-Core' 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | GAAbstractMutationOperation >> doMutate: individual [ 12 | "To be overridden" 13 | self subclassResponsibility 14 | ] 15 | 16 | { #category : #'as yet unclassified' } 17 | GAAbstractMutationOperation >> geneFactoryBlock: oneArgBlock [ 18 | "Do nothing. May be overridden if necessary" 19 | ] 20 | 21 | { #category : #'as yet unclassified' } 22 | GAAbstractMutationOperation >> initialize [ 23 | super initialize. 24 | self mutationRate: 0.01 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | GAAbstractMutationOperation >> mutate: individual [ 29 | "Return a new individual (different object than the argument), result of a mutation from the individual provided as argument." 30 | | newIndividual | 31 | newIndividual := GAIndividual new. 32 | newIndividual random: random. 33 | newIndividual genes: individual genes copy. 34 | self doMutate: newIndividual. 35 | ^ newIndividual 36 | ] 37 | 38 | { #category : #'as yet unclassified' } 39 | GAAbstractMutationOperation >> mutationRate [ 40 | "Return the used mutation rate. Typically, a small positive number, close to 0.0 and significantly less than 1.0" 41 | ^ mutationRate 42 | ] 43 | 44 | { #category : #'as yet unclassified' } 45 | GAAbstractMutationOperation >> mutationRate: aFloat [ 46 | "Set the mutation rate. Typically, a small positive number, close to 0.0 and significantly less than 1.0" 47 | mutationRate := aFloat 48 | ] 49 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAConstrainedCrossoverOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAConstrainedCrossoverOperation, 3 | #superclass : #GAAbstractCrossoverOperation, 4 | #instVars : [ 5 | 'possibleCutpoints' 6 | ], 7 | #category : #'GeneticAlgorithm-Core' 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | GAConstrainedCrossoverOperation >> pickCutPointFor: partnerA [ 12 | "Return a cutpoint" 13 | self assert: [ possibleCutpoints notNil ] description: 14 | 'Need to provide the possible cut points, using #possibleCutpoints:'. 15 | ^ possibleCutpoints at: (random nextInt: possibleCutpoints size) 16 | ] 17 | 18 | { #category : #'as yet unclassified' } 19 | GAConstrainedCrossoverOperation >> possibleCutpoints: indexes [ 20 | "Set the possible pointcuts considered by the operator" 21 | possibleCutpoints := indexes 22 | ] 23 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GACrossoverOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GACrossoverOperation, 3 | #superclass : #GAAbstractCrossoverOperation, 4 | #category : #'GeneticAlgorithm-Core' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | GACrossoverOperation >> pickCutPointFor: partnerA [ 9 | 10 | "Simply returns a random number between 1 and the number of genes of the individual provided as argument" 11 | 12 | ^ random nextInteger: partnerA numberOfGenes 13 | ] 14 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAIndividual.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAIndividual, 3 | #superclass : #GAObject, 4 | #instVars : [ 5 | 'genes', 6 | 'fitness' 7 | ], 8 | #category : #'GeneticAlgorithm-Core' 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | GAIndividual class >> create: numberOfIndividuals individualsAndInitialize: numberOfGenes genesWith: geneBlockFactory [ 13 | "Factory method to easily create a number of Individuals. 14 | numberOfIndividuals : is the number of individuals to return 15 | numberOfGenes : number of genes each individual should have 16 | geneBlockFactory : is a one-argument block to generate a gene. It takes a random generator as argument" 17 | ^ self create: numberOfIndividuals individualsAndInitialize: numberOfGenes genesWith: geneBlockFactory using: (Random new seed: 42) 18 | ] 19 | 20 | { #category : #'as yet unclassified' } 21 | GAIndividual class >> create: numberOfIndividuals individualsAndInitialize: numberOfGenes genesWith: geneBlockFactory using: randomNumberGeneration [ 22 | "Factory method to easily create a population of Individuals. 23 | numberOfIndividuals : is the number of individuals to return 24 | numberOfGenes : number of genes each individual should have 25 | geneBlockFactory : is a one-argument block to generate a gene. It takes a random generator as argument 26 | randomNumberGeneration : is a random generator" 27 | | someIndividuals ind | 28 | someIndividuals := OrderedCollection new. 29 | numberOfIndividuals timesRepeat: [ 30 | ind := self new. 31 | ind random: randomNumberGeneration. 32 | ind set: numberOfGenes genesUsing: geneBlockFactory. 33 | someIndividuals add: ind ]. 34 | ^ someIndividuals 35 | ] 36 | 37 | { #category : #'as yet unclassified' } 38 | GAIndividual >> computeFitnessUsing: fitnessBlock [ 39 | "Compute the fitness of myself if not already computed" 40 | self assert: [ genes notNil ] description: 'Need to have some genes first'. 41 | 42 | "Simply exit if already computed" 43 | fitness ifNotNil: [ ^ self ]. 44 | 45 | "Compute the fitness score" 46 | fitness := fitnessBlock value: genes 47 | ] 48 | 49 | { #category : #'as yet unclassified' } 50 | GAIndividual >> fitness [ 51 | "Return the fitness value of the individual" 52 | ^ fitness 53 | ] 54 | 55 | { #category : #'as yet unclassified' } 56 | GAIndividual >> genes [ 57 | "Return the individual's genes" 58 | ^ genes 59 | ] 60 | 61 | { #category : #'as yet unclassified' } 62 | GAIndividual >> genes: someGenes [ 63 | "Set the genes of the individual. Used by the genetic operations." 64 | genes := someGenes 65 | ] 66 | 67 | { #category : #'as yet unclassified' } 68 | GAIndividual >> numberOfGenes [ 69 | "Return the number of genes the individual has" 70 | ^ self genes size 71 | ] 72 | 73 | { #category : #'as yet unclassified' } 74 | GAIndividual >> set: numberOfGenes genesUsing: geneBlockFactory [ 75 | "Public method - Generate the genes of the individual" 76 | 77 | self checkForRandomNumber. 78 | genes := (1 to: numberOfGenes) 79 | collect: [ :index | geneBlockFactory cull: random cull: index cull: self ] 80 | ] 81 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GALog.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GALog, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'generationNumber', 6 | 'timeToProduceGeneration', 7 | 'fittestIndividual', 8 | 'worseFitness', 9 | 'averageFitness', 10 | 'time' 11 | ], 12 | #category : #'GeneticAlgorithm-Core' 13 | } 14 | 15 | { #category : #'as yet unclassified' } 16 | GALog >> averageFitness [ 17 | "Return the average fitness value of a generation I am representing" 18 | ^ averageFitness 19 | ] 20 | 21 | { #category : #'as yet unclassified' } 22 | GALog >> averageFitness: aNumber [ 23 | "Set the average fitness value of a generation I am representing" 24 | averageFitness := aNumber 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | GALog >> bestFitness [ 29 | "Return the best fitness value of a generation I am representing" 30 | ^ fittestIndividual fitness 31 | ] 32 | 33 | { #category : #'as yet unclassified' } 34 | GALog >> fittestIndividual [ 35 | "Return the best individual of the generation I represent" 36 | ^ fittestIndividual 37 | ] 38 | 39 | { #category : #'as yet unclassified' } 40 | GALog >> fittestIndividual: anIndividual [ 41 | "Set the best individual of the generation I represent" 42 | fittestIndividual := anIndividual 43 | ] 44 | 45 | { #category : #'as yet unclassified' } 46 | GALog >> generationNumber [ 47 | "Return the generation number I represent" 48 | ^ generationNumber 49 | ] 50 | 51 | { #category : #'as yet unclassified' } 52 | GALog >> generationNumber: generationNumberAsInteger [ 53 | "Set the generation number I am representing" 54 | generationNumber := generationNumberAsInteger 55 | ] 56 | 57 | { #category : #'as yet unclassified' } 58 | GALog >> initialize [ 59 | super initialize. 60 | time := DateAndTime now 61 | ] 62 | 63 | { #category : #'as yet unclassified' } 64 | GALog >> printOn: str [ 65 | "Printing the log object" 66 | super printOn: str. 67 | str nextPut: $<. 68 | str nextPutAll: fittestIndividual genes asString. 69 | str nextPut: $>. 70 | ] 71 | 72 | { #category : #'as yet unclassified' } 73 | GALog >> time [ 74 | "Return the time the log was created" 75 | ^ time 76 | ] 77 | 78 | { #category : #'as yet unclassified' } 79 | GALog >> timeToProduceGeneration [ 80 | "Time to produce the generation I represent" 81 | ^ timeToProduceGeneration 82 | ] 83 | 84 | { #category : #'as yet unclassified' } 85 | GALog >> timeToProduceGeneration: anInteger [ 86 | "Set the time to produce the generation I am representing" 87 | timeToProduceGeneration := anInteger 88 | ] 89 | 90 | { #category : #'as yet unclassified' } 91 | GALog >> worseFitness [ 92 | "Return the worse fitness value of a generation I am representing" 93 | ^ worseFitness 94 | ] 95 | 96 | { #category : #'as yet unclassified' } 97 | GALog >> worseFitness: aNumber [ 98 | "Set the worst fitness value of a generation I am representing" 99 | worseFitness := aNumber 100 | ] 101 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAMutationOperation, 3 | #superclass : #GAAbstractMutationOperation, 4 | #instVars : [ 5 | 'geneFactoryBlock' 6 | ], 7 | #category : #'GeneticAlgorithm-Core' 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | GAMutationOperation >> checkForGeneFactory [ 12 | self 13 | assert: [ geneFactoryBlock notNil ] 14 | description: 'Need to provide a block to create gene' 15 | ] 16 | 17 | { #category : #'as yet unclassified' } 18 | GAMutationOperation >> doMutate: individual [ 19 | "Mutate genes of the argument" 20 | self checkForRandomNumber. 21 | self checkForGeneFactory. 22 | 1 to: individual genes size do: [ :index | 23 | self randomNumber <= mutationRate 24 | ifTrue: [ individual genes at: index put: (geneFactoryBlock cull: random cull: index cull: individual) ] ] 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | GAMutationOperation >> geneFactoryBlock [ 29 | "Return the three-arg block used to create a gene, following the pattern 30 | [ :rand :index :ind | ... ] 31 | rand is the random number generator, 32 | index is index of the gene, 33 | ind is the individual being filled" 34 | 35 | ^ geneFactoryBlock 36 | ] 37 | 38 | { #category : #'as yet unclassified' } 39 | GAMutationOperation >> geneFactoryBlock: oneArgBlock [ 40 | "The block receive a random number as argument" 41 | geneFactoryBlock := oneArgBlock 42 | ] 43 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAObject.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAObject, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'random' 6 | ], 7 | #category : #'GeneticAlgorithm-Core' 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | GAObject >> checkForRandomNumber [ 12 | self 13 | assert: [ random notNil ] 14 | description: 'Need to provide a random number generator' 15 | ] 16 | 17 | { #category : #'as yet unclassified' } 18 | GAObject >> random [ 19 | "Return the random number generator associated to the object" 20 | ^ random 21 | ] 22 | 23 | { #category : #'as yet unclassified' } 24 | GAObject >> random: aRandomNumberGenerator [ 25 | "Set the random number generator associated to the object. The argument must be an instance of Random." 26 | random := aRandomNumberGenerator 27 | ] 28 | 29 | { #category : #'as yet unclassified' } 30 | GAObject >> randomNumber [ 31 | "Return a number between 0.0 and 1.0" 32 | ^ random next 33 | ] 34 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAOperation, 3 | #superclass : #GAObject, 4 | #category : #'GeneticAlgorithm-Core' 5 | } 6 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GAOrderedCrossoverOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAOrderedCrossoverOperation, 3 | #superclass : #GAAbstractCrossoverOperation, 4 | #category : #'GeneticAlgorithm-Core' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | GAOrderedCrossoverOperation >> crossover: individualA with: individualB [ 9 | "Return a new child, which is the result of mixing the two individuals" 10 | | i1 i2 | 11 | i1 := self pickCutPointFor: individualA. 12 | i2 := self pickCutPointFor: individualA. 13 | 14 | "Make sure that i1 is smaller than i2" 15 | (i1 > i2) ifTrue: [ | t | t := i1. i1 := i2. i2 := t ]. 16 | ^ self crossover: individualA with: individualB from: i1 to: i2 17 | ] 18 | 19 | { #category : #'as yet unclassified' } 20 | GAOrderedCrossoverOperation >> crossover: individualA with: individualB from: i1 to: i2 [ 21 | "Return a new child, which is the result of mixing myself the two individuals. The method assumes that i1 <= i2." 22 | 23 | | child crossOverGenes runningIndex swath | 24 | child := GAIndividual new. 25 | child random: random. 26 | 27 | swath := individualA genes copyFrom: i1 to: i2. 28 | crossOverGenes := Array new: individualA genes size. 29 | crossOverGenes := crossOverGenes copyReplaceFrom: i1 to: i2 with: swath. 30 | 31 | runningIndex := 1. 32 | (individualB genes copyWithoutAll: swath) 33 | do: [ :v | (crossOverGenes includes: v) ifFalse: [ 34 | [(crossOverGenes at: runningIndex) notNil] whileTrue: [ runningIndex := runningIndex + 1 ]. 35 | crossOverGenes at: runningIndex put: v ] ]. 36 | 37 | child genes: crossOverGenes. 38 | ^ child 39 | ] 40 | 41 | { #category : #'as yet unclassified' } 42 | GAOrderedCrossoverOperation >> pickCutPointFor: partner [ 43 | "Simply return a random number between 1 and the number of genes of the individual provided as argument" 44 | ^ random nextInt: partner genes size 45 | ] 46 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GASwapMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GASwapMutationOperation, 3 | #superclass : #GAAbstractMutationOperation, 4 | #category : #'GeneticAlgorithm-Core' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | GASwapMutationOperation >> doMutate: individual [ 9 | "Mutate genes of the argument by swapping two gene values" 10 | 11 | | i2 tmp | 12 | self checkForRandomNumber. 13 | 1 to: individual genes size do: [ :i1 | 14 | self randomNumber <= mutationRate 15 | ifTrue: [ 16 | i2 := random nextInt: individual genes size. 17 | tmp := individual genes at: i1. 18 | individual genes at: i1 put: (individual genes at: i2). 19 | individual genes at: i2 put: tmp ] ] 20 | ] 21 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/GATournamentSelection.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GATournamentSelection, 3 | #superclass : #GASelection, 4 | #instVars : [ 5 | 'tournamentSize' 6 | ], 7 | #category : #'GeneticAlgorithm-Core' 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | GATournamentSelection >> createNewPopulation [ 12 | "Return a new population made of newly breed individual" 13 | | partnerA partnerB child | 14 | population := (1 to: self populationSize) collect: [ :seed | 15 | engine random: (Random seed: seed). 16 | partnerA := self getGoodIndividual. 17 | partnerB := self getGoodIndividual. 18 | child := self mutate: (self crossover: partnerA with: partnerB). 19 | child computeFitnessUsing: engine fitnessBlock. 20 | child. 21 | ] 22 | ] 23 | 24 | { #category : #'as yet unclassified' } 25 | GATournamentSelection >> getGoodIndividual [ 26 | "Return the best individual from tournamentSize individual randomly chosen from the population" 27 | | best ind | 28 | best := nil. 29 | tournamentSize timesRepeat: [ 30 | ind := initialPopulation at: (self randomNumber: initialPopulation size). 31 | (best isNil or: [ compareFitness value: ind fitness value: best fitness ]) 32 | ifTrue: [ best := ind ] ]. 33 | ^ best 34 | ] 35 | 36 | { #category : #'as yet unclassified' } 37 | GATournamentSelection >> initialize [ 38 | super initialize. 39 | tournamentSize := 5 40 | ] 41 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Core/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'GeneticAlgorithm-Core' } 2 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Tests/GACrossoverOperationTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GACrossoverOperationTest, 3 | #superclass : #TestCase, 4 | #instVars : [ 5 | 'i1', 6 | 'i2', 7 | 'op' 8 | ], 9 | #category : #'GeneticAlgorithm-Tests' 10 | } 11 | 12 | { #category : #'as yet unclassified' } 13 | GACrossoverOperationTest >> setUp [ 14 | super setUp. 15 | i1 := GAIndividual new genes: 'abcd'. 16 | i2 := GAIndividual new genes: 'defg'. 17 | op := GACrossoverOperation new. 18 | ] 19 | 20 | { #category : #'as yet unclassified' } 21 | GACrossoverOperationTest >> testCrossover1 [ 22 | | i3 | 23 | i3 := op crossover: i1 with: i2 midpoint: 2. 24 | self assert: i3 genes equals: 'abfg' 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | GACrossoverOperationTest >> testCrossover2 [ 29 | | i3 | 30 | i3 := op crossover: i1 with: i2 midpoint: 1. 31 | self assert: i3 genes equals: 'aefg' 32 | ] 33 | 34 | { #category : #'as yet unclassified' } 35 | GACrossoverOperationTest >> testCrossover3 [ 36 | | i3 | 37 | i3 := op crossover: i1 with: i2 midpoint: 0. 38 | self assert: i3 genes equals: 'defg' 39 | ] 40 | 41 | { #category : #'as yet unclassified' } 42 | GACrossoverOperationTest >> testCrossover4 [ 43 | | i3 | 44 | op random: (Random seed: 42). 45 | i3 := op crossover: i1 with: i2. 46 | self assert: i3 genes equals: 'aefg' 47 | ] 48 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Tests/GAEngineTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAEngineTest, 3 | #superclass : #TestCase, 4 | #category : #'GeneticAlgorithm-Tests' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | GAEngineTest >> testExamples01 [ 9 | | g | 10 | g := GAEngine new. 11 | g populationSize: 1000. 12 | g numberOfGenes: 4. 13 | g createGeneBlock: [ :rand :index :ind | ($a to: $z) atRandom: rand ]. 14 | g fitnessBlock: [ :genes | 15 | (#($g $a $t $o) with: genes collect: [ :a :b | 16 | a = b ifTrue: [ 1 ] ifFalse: [ 0 ] ]) sum ]. 17 | g run. 18 | self assert: g logs first fittestIndividual fitness equals: 2. 19 | self assert: g logs first fittestIndividual genes equals: #($g $l $t $s). 20 | self assert: g logs fourth fittestIndividual fitness equals: 4. 21 | self assert: g logs fourth fittestIndividual genes equals: #($g $a $t $o). 22 | ] 23 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Tests/GAIndividualTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAIndividualTest, 3 | #superclass : #TestCase, 4 | #category : #'GeneticAlgorithm-Tests' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | GAIndividualTest >> testCreationWithCharacters [ 9 | | r individuals f ind | 10 | r := Random seed: 42. 11 | f := [ :random | ($a to: $z) atRandom: random ]. 12 | individuals := GAIndividual 13 | create: 100 14 | individualsAndInitialize: 10 15 | genesWith: f 16 | using: r. 17 | 18 | self assert: individuals size equals: 100. 19 | self assert: (individuals collect: #numberOfGenes) asSet asArray equals: #(10). 20 | 21 | ind := individuals anyOne. 22 | self assert: (ind genes allSatisfy: [ :c | ($a to: $z) includes: c ]). 23 | ] 24 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Tests/GAMutationOperationTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAMutationOperationTest, 3 | #superclass : #TestCase, 4 | #instVars : [ 5 | 'i', 6 | 'op' 7 | ], 8 | #category : #'GeneticAlgorithm-Tests' 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | GAMutationOperationTest >> setUp [ 13 | super setUp. 14 | i := GAIndividual new genes: 'abcd' asArray. 15 | op := GAMutationOperation new. 16 | ] 17 | 18 | { #category : #'as yet unclassified' } 19 | GAMutationOperationTest >> testMutation [ 20 | | i2 | 21 | op random: (Random seed: 7). 22 | op geneFactoryBlock: [ :r | ($a to: $z) atRandom: r ]. 23 | op mutationRate: 0.5. 24 | 25 | i2 := op mutate: i. 26 | self assert: i2 genes equals: 'xfcd' asArray. 27 | 28 | i2 := op mutate: i2. 29 | self assert: i2 genes equals: 'tfcd' asArray. 30 | 31 | i2 := op mutate: i2. 32 | self assert: i2 genes equals: 'tfjd' asArray. 33 | ] 34 | 35 | { #category : #'as yet unclassified' } 36 | GAMutationOperationTest >> testRandomAndGeneFactoryMustBeSet [ 37 | self should: [ op mutate: i ] raise: AssertionFailure. 38 | 39 | op random: Random new. 40 | self should: [ op mutate: i ] raise: AssertionFailure. 41 | 42 | op geneFactoryBlock: [ :r | 42 ]. 43 | self shouldnt: [ op mutate: i ] raise: AssertionFailure. 44 | ] 45 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Tests/GAOrderedCrossoverOperationTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GAOrderedCrossoverOperationTest, 3 | #superclass : #TestCase, 4 | #instVars : [ 5 | 'i1', 6 | 'i2', 7 | 'op' 8 | ], 9 | #category : #'GeneticAlgorithm-Tests' 10 | } 11 | 12 | { #category : #'as yet unclassified' } 13 | GAOrderedCrossoverOperationTest >> setUp [ 14 | super setUp. 15 | i1 := GAIndividual new genes: #(8 4 7 3 6 2 5 1 9 0). 16 | i2 := GAIndividual new genes: #(0 1 2 3 4 5 6 7 8 9). 17 | op := GAOrderedCrossoverOperation new. 18 | ] 19 | 20 | { #category : #'as yet unclassified' } 21 | GAOrderedCrossoverOperationTest >> testCrossover1 [ 22 | | i3 | 23 | i3 := op crossover: i1 with: i2 from: 4 to: 8. 24 | self assert: i3 genes equals: #(0 4 7 3 6 2 5 1 8 9). 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | GAOrderedCrossoverOperationTest >> testCrossover2 [ 29 | | i3 | 30 | i3 := op crossover: i1 with: i2 from: 1 to: 4. 31 | self assert: i3 genes equals: #(8 4 7 3 0 1 2 5 6 9). 32 | ] 33 | 34 | { #category : #'as yet unclassified' } 35 | GAOrderedCrossoverOperationTest >> testCrossover3 [ 36 | | i3 | 37 | i3 := op crossover: i1 with: i2 from: 9 to: 10. 38 | self assert: i3 genes equals: #(1 2 3 4 5 6 7 8 9 0). 39 | ] 40 | 41 | { #category : #'as yet unclassified' } 42 | GAOrderedCrossoverOperationTest >> testCrossover4 [ 43 | | i3 | 44 | i1 := GAIndividual new genes: #(1 2 3 4 5 6 7 8 9). 45 | i2 := GAIndividual new genes: #(9 8 7 6 5 4 3 2 1). 46 | 47 | i3 := op crossover: i1 with: i2 from: 6 to: 8. 48 | self assert: i3 genes equals: #(9 5 4 3 2 6 7 8 1). 49 | ] 50 | -------------------------------------------------------------------------------- /src/GeneticAlgorithm-Tests/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'GeneticAlgorithm-Tests' } 2 | -------------------------------------------------------------------------------- /src/Matrix/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #Matrix } 2 | -------------------------------------------------------------------------------- /src/MiniMario/MNAIMario.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #MNAIMario, 3 | #superclass : #MNMario, 4 | #instVars : [ 5 | 'network' 6 | ], 7 | #category : #MiniMario 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | MNAIMario >> beat [ 12 | | actionToPerform | 13 | super beat. 14 | actionToPerform := network predict: game whatMarioSees. 15 | actionToPerform = 0 ifTrue: [ self moveLeft ]. 16 | actionToPerform = 1 ifTrue: [ self moveRight ]. 17 | actionToPerform = 2 ifTrue: [ self jump ]. 18 | ] 19 | 20 | { #category : #'as yet unclassified' } 21 | MNAIMario >> network: aNeuralNetwork [ 22 | "Set the neural network meant to be used by Mario" 23 | network := aNeuralNetwork 24 | ] 25 | -------------------------------------------------------------------------------- /src/MiniMario/MNMario.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #MNMario, 3 | #superclass : #MNAbstractCharacter, 4 | #category : #MiniMario 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | MNMario >> beat [ 9 | super beat. 10 | "The game ends if Mario reaches the 11 | right-most position of the game" 12 | self position x = (game size x - 1) ifTrue: [ game gameOver ]. 13 | 14 | "The game also ends if Mario bumps into a monster" 15 | game monsters do: [ :m | 16 | (m position = self position) ifTrue: [ game gameOver ] ] 17 | ] 18 | -------------------------------------------------------------------------------- /src/MiniMario/MNMonster.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #MNMonster, 3 | #superclass : #MNAbstractCharacter, 4 | #instVars : [ 5 | 'movingLeft', 6 | 'pauseCounter' 7 | ], 8 | #category : #MiniMario 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | MNMonster >> beat [ 13 | "A monster can go to the left or to the right" 14 | super beat. 15 | pauseCounter := pauseCounter + 1. 16 | pauseCounter < 10 ifTrue: [ ^ self ]. 17 | pauseCounter := 0. 18 | 19 | movingLeft 20 | ifTrue: [ (self canGoToward: -1 @ 0) ifFalse: [ movingLeft := false ] ] 21 | ifFalse: [ (self canGoToward: 1 @ 0) ifFalse: [ movingLeft := true ] ]. 22 | 23 | movingLeft ifTrue: [ self moveLeft ] ifFalse: [ self moveRight ]. 24 | ] 25 | 26 | { #category : #'as yet unclassified' } 27 | MNMonster >> initialize [ 28 | super initialize. 29 | movingLeft := true. 30 | pauseCounter := 0 31 | ] 32 | -------------------------------------------------------------------------------- /src/MiniMario/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #MiniMario } 2 | -------------------------------------------------------------------------------- /src/NEAT/NEAbstractMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEAbstractMutationOperation, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'random' 6 | ], 7 | #category : #NEAT 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | NEAbstractMutationOperation >> on: anIndividual [ 12 | "Override this method to perform the mutation" 13 | self subclassResponsibility 14 | ] 15 | 16 | { #category : #'as yet unclassified' } 17 | NEAbstractMutationOperation >> performOn: anIndividual [ 18 | "Public method that perform a mutation on the argument 19 | the method modifies anIndividual" 20 | random := anIndividual random. 21 | anIndividual resetFitness. 22 | self on: anIndividual 23 | ] 24 | 25 | { #category : #'as yet unclassified' } 26 | NEAbstractMutationOperation >> random: aRandomNumberGenerator [ 27 | random := aRandomNumberGenerator 28 | ] 29 | 30 | { #category : #'as yet unclassified' } 31 | NEAbstractMutationOperation >> randomWeight [ 32 | "Return a random number within -5 and 5" 33 | ^ random next * 10 - 5 34 | ] 35 | -------------------------------------------------------------------------------- /src/NEAT/NEAbstractNonStructuralMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEAbstractNonStructuralMutationOperation, 3 | #superclass : #NEAbstractMutationOperation, 4 | #category : #NEAT 5 | } 6 | -------------------------------------------------------------------------------- /src/NEAT/NEAbstractStructuralMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEAbstractStructuralMutationOperation, 3 | #superclass : #NEAbstractMutationOperation, 4 | #classVars : [ 5 | 'InnovationNumber' 6 | ], 7 | #category : #NEAT 8 | } 9 | 10 | { #category : #'as yet unclassified' } 11 | NEAbstractStructuralMutationOperation >> performOn: anIndividual [ 12 | InnovationNumber isNil ifTrue: [ InnovationNumber := 1 ]. 13 | InnovationNumber := InnovationNumber + 1. 14 | super performOn: anIndividual. 15 | ] 16 | -------------------------------------------------------------------------------- /src/NEAT/NEAddConnectionMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEAddConnectionMutationOperation, 3 | #superclass : #NEAbstractStructuralMutationOperation, 4 | #category : #NEAT 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | NEAddConnectionMutationOperation >> findMissingConnectionIn: anIndividual nbTry: nbTry [ 9 | "Return an array containing two nodes. 10 | Only a finite number of tries are made to find those nodes." 11 | | node1 node2 | 12 | "If we made our tries, then we return nil meaning that no connections can be made" 13 | nbTry = 0 ifTrue: [ ^ nil ]. 14 | 15 | "The connection goes from node1 to node2. node1 cannot be an output node therefore" 16 | node1 := (anIndividual nodes reject: #isOutput) atRandom: random. 17 | 18 | "Similarly, node2 cannot be an input node." 19 | node2 := (anIndividual nodes reject: #isInput) atRandom: random. 20 | 21 | "Is there already a connection from node1 to node2?" 22 | (anIndividual connections anySatisfy: [ :c | 23 | (c in = node1 id and: [ c out = node2 id ]) ]) ifTrue: [ 24 | "If yes, then we iterate once more" 25 | ^ self findMissingConnectionIn: anIndividual nbTry: (nbTry - 1) ]. 26 | 27 | "We check if there is no path going from node2 to node1. 28 | Adding a connection should not introduce a cycle" 29 | (self is: node1 accessibleFrom: node2 in: anIndividual) 30 | ifTrue: [ ^ self findMissingConnectionIn: anIndividual nbTry: (nbTry - 1) ]. 31 | 32 | ^ { node1 id . node2 id } 33 | ] 34 | 35 | { #category : #'as yet unclassified' } 36 | NEAddConnectionMutationOperation >> is: node1 accessibleFrom: node2 in: anIndividual [ 37 | "Is there a path going from node2 to node1?" 38 | anIndividual buildNetwork. 39 | ^ self privateIs: node1 accessibleFrom: node2 40 | ] 41 | 42 | { #category : #'as yet unclassified' } 43 | NEAddConnectionMutationOperation >> on: anIndividual [ 44 | "Add a connection between two nodes to an individual" 45 | | array | 46 | "Find two nodes in which we can add a connection. No more 47 | than 5 tries are made" 48 | array := self findMissingConnectionIn: anIndividual nbTry: 5. 49 | 50 | "We did not find a solution, so we merely exit. There is not much we can do" 51 | array ifNil: [ ^ self ]. 52 | 53 | "Else, we add the connection" 54 | anIndividual 55 | addConnection: 56 | (NEConnection new 57 | in: array first; 58 | out: array second; 59 | weight: self randomWeight; 60 | makeEnabled; 61 | innovationNumber: InnovationNumber) 62 | ] 63 | 64 | { #category : #'as yet unclassified' } 65 | NEAddConnectionMutationOperation >> privateIs: node1 accessibleFrom: node2 [ 66 | "Recursively look for a path from node2 to node1" 67 | node1 == node2 ifTrue: [ ^ true ]. 68 | node2 connectedNodes do: [ :n | 69 | node1 == n ifTrue: [ ^ true ]. 70 | (self privateIs: node1 accessibleFrom: n) ifTrue: [ ^ true ] ]. 71 | ^ false 72 | ] 73 | -------------------------------------------------------------------------------- /src/NEAT/NEAddNodeMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEAddNodeMutationOperation, 3 | #superclass : #NEAbstractStructuralMutationOperation, 4 | #category : #NEAT 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | NEAddNodeMutationOperation >> on: anIndividual [ 9 | "Add a hidden node and two connections in the individual" 10 | | relevantConnections c | 11 | relevantConnections := anIndividual connections select: #isEnabled. 12 | relevantConnections ifEmpty: [ ^self ]. 13 | 14 | "We pick a random connection and disable it" 15 | c := relevantConnections atRandom: anIndividual random. 16 | c makeDisabled. 17 | 18 | "We add a hidden node ..." 19 | anIndividual addHiddenNode innovationNumber: InnovationNumber. 20 | 21 | "... and two connections" 22 | anIndividual addConnection: 23 | (NEConnection new in: c in; out: anIndividual numberOfNodesWithBias; weight: 1; makeEnabled; innovationNumber: InnovationNumber). 24 | anIndividual addConnection: 25 | (NEConnection new in: anIndividual numberOfNodesWithBias; out: c out; weight: c weight; makeEnabled; innovationNumber: InnovationNumber). 26 | ] 27 | -------------------------------------------------------------------------------- /src/NEAT/NEConnection.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEConnection, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'in', 6 | 'out', 7 | 'weight', 8 | 'enabled', 9 | 'innovationNumber' 10 | ], 11 | #category : #NEAT 12 | } 13 | 14 | { #category : #'as yet unclassified' } 15 | NEConnection >> in [ 16 | "Return the index of the input node in the individual" 17 | ^ in 18 | ] 19 | 20 | { #category : #'as yet unclassified' } 21 | NEConnection >> in: anInteger [ 22 | "Set the in node index" 23 | in := anInteger 24 | ] 25 | 26 | { #category : #'as yet unclassified' } 27 | NEConnection >> innovationNumber [ 28 | "Return the historical marker of the connection, the innovation number" 29 | ^ innovationNumber 30 | ] 31 | 32 | { #category : #'as yet unclassified' } 33 | NEConnection >> innovationNumber: anInteger [ 34 | "Set the innovation number" 35 | innovationNumber := anInteger 36 | ] 37 | 38 | { #category : #'as yet unclassified' } 39 | NEConnection >> isEnabled [ 40 | "Return true if the connection is enabled" 41 | ^ enabled 42 | ] 43 | 44 | { #category : #'as yet unclassified' } 45 | NEConnection >> makeDisabled [ 46 | "Disable the connection" 47 | enabled := false 48 | ] 49 | 50 | { #category : #'as yet unclassified' } 51 | NEConnection >> makeEnabled [ 52 | "Enable the connection" 53 | enabled := true 54 | ] 55 | 56 | { #category : #'as yet unclassified' } 57 | NEConnection >> out [ 58 | "Return the index of the output node in the individual" 59 | ^ out 60 | ] 61 | 62 | { #category : #'as yet unclassified' } 63 | NEConnection >> out: anInteger [ 64 | "Set the out node index" 65 | out := anInteger 66 | ] 67 | 68 | { #category : #'as yet unclassified' } 69 | NEConnection >> weight [ 70 | "Return the weight of the connection" 71 | ^ weight 72 | ] 73 | 74 | { #category : #'as yet unclassified' } 75 | NEConnection >> weight: aNumber [ 76 | "Set the weight for the connection" 77 | weight := aNumber 78 | ] 79 | -------------------------------------------------------------------------------- /src/NEAT/NEConnectionWeightMutationOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NEConnectionWeightMutationOperation, 3 | #superclass : #NEAbstractNonStructuralMutationOperation, 4 | #category : #NEAT 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | NEConnectionWeightMutationOperation >> on: anIndividual [ 9 | "Modify the weight of a connection" 10 | | c | 11 | anIndividual connections ifEmpty: [ ^ self ]. 12 | c := (anIndividual connections atRandom: random). 13 | c weight: self randomWeight + c weight 14 | ] 15 | -------------------------------------------------------------------------------- /src/NEAT/NECrossoverOperation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NECrossoverOperation, 3 | #superclass : #Object, 4 | #category : #NEAT 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | NECrossoverOperation >> performOn: i1 and: i2 [ 9 | "Return a child individual that is the result of a crossover between individuals i1 and i2" 10 | "The method ASSUMES that the fitness of i1 is higher than the one of i2" 11 | 12 | | newConnections indexI1 indexI2 shouldIterate newNodes | 13 | "newNodes are the nodes of the child individual. 14 | It is simply a copy of the nodes of the best individual, i1." 15 | newNodes := i1 nodes collect: #copy. 16 | 17 | "newConnections are the connections of the child individual" 18 | newConnections := OrderedCollection new. 19 | 20 | "If any individuals has no connection, then we create a new individual with no connection" 21 | (i1 connections notEmpty and: [ i2 connections notEmpty ]) 22 | ifFalse: [ ^ NEIndividual new nodes: newNodes; connections: newConnections; random: i1 random ]. 23 | 24 | "We initialize some temporary variables" 25 | indexI1 := 1. 26 | indexI2 := 1. 27 | shouldIterate := true. 28 | 29 | "The iteration loop" 30 | [ shouldIterate ] whileTrue: [ 31 | | c1 c2 | 32 | indexI1 := indexI1 min: i1 numberOfConnections. 33 | indexI2 := indexI2 min: i2 numberOfConnections. 34 | c1 := i1 connections at: indexI1. 35 | c2 := i2 connections at: indexI2. 36 | c1 innovationNumber = c2 innovationNumber 37 | ifTrue: [ 38 | newConnections add: (i1 random next > 0.5 ifTrue: [ c1 ] ifFalse: [ c2 ]) copy. 39 | indexI1 := indexI1 + 1. 40 | indexI2 := indexI2 + 1. ] 41 | ifFalse: [ shouldIterate := false ]. 42 | 43 | (indexI1 >= i1 numberOfConnections and: [ indexI2 >= i2 numberOfConnections ]) 44 | ifTrue: [ shouldIterate := false ] 45 | ]. 46 | "We consider the remainder connection from the best individual" 47 | newConnections addAll: ((i1 connections allButFirst: indexI1 - 1) collect: #copy). 48 | 49 | "A new individual is returned" 50 | ^ NEIndividual new nodes: newNodes; connections: newConnections; random: i1 random 51 | ] 52 | -------------------------------------------------------------------------------- /src/NEAT/NELog.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NELog, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'generation', 6 | 'speciation', 7 | 'minFitness', 8 | 'maxFitness', 9 | 'averageFitness', 10 | 'bestIndividual' 11 | ], 12 | #category : #NEAT 13 | } 14 | 15 | { #category : #'as yet unclassified' } 16 | NELog >> averageFitness [ 17 | "Return the average population fitness" 18 | ^ averageFitness 19 | ] 20 | 21 | { #category : #'as yet unclassified' } 22 | NELog >> averageFitness: aNumber [ 23 | "Set the average population fitness" 24 | averageFitness := aNumber 25 | ] 26 | 27 | { #category : #'as yet unclassified' } 28 | NELog >> bestIndividual [ 29 | "Return the best individual of the population" 30 | ^ bestIndividual 31 | ] 32 | 33 | { #category : #'as yet unclassified' } 34 | NELog >> bestIndividual: anIndividual [ 35 | "Set the best individual of the population" 36 | bestIndividual := anIndividual 37 | ] 38 | 39 | { #category : #'as yet unclassified' } 40 | NELog >> generation [ 41 | "Return the generation number represented by the log" 42 | ^ generation 43 | ] 44 | 45 | { #category : #'as yet unclassified' } 46 | NELog >> generation: anInteger [ 47 | "Set the generation number" 48 | generation := anInteger 49 | ] 50 | 51 | { #category : #'as yet unclassified' } 52 | NELog >> gtInspectorViewIn: composite [ 53 | 54 | composite roassal2 55 | title: 'View'; 56 | initializeView: [ speciation visualize ] 57 | ] 58 | 59 | { #category : #'as yet unclassified' } 60 | NELog >> maxFitness [ 61 | "Return the maximum fitness" 62 | ^ maxFitness 63 | ] 64 | 65 | { #category : #'as yet unclassified' } 66 | NELog >> maxFitness: aNumber [ 67 | "Set the maximum fitness" 68 | maxFitness := aNumber 69 | ] 70 | 71 | { #category : #'as yet unclassified' } 72 | NELog >> minFitness [ 73 | "Return the minimum fitness" 74 | ^ minFitness 75 | ] 76 | 77 | { #category : #'as yet unclassified' } 78 | NELog >> minFitness: aNumber [ 79 | "Set the minimum fitness" 80 | minFitness := aNumber 81 | ] 82 | 83 | { #category : #'as yet unclassified' } 84 | NELog >> numberOfSpecies [ 85 | "Return the number of species in the speciation" 86 | speciation ifNil: [ ^ 0 ]. 87 | ^ speciation numberOfSpecies 88 | ] 89 | 90 | { #category : #'as yet unclassified' } 91 | NELog >> release [ 92 | "Release the specification, and thus reduce the amount of consumed memory" 93 | speciation := nil. 94 | bestIndividual := nil 95 | ] 96 | 97 | { #category : #'as yet unclassified' } 98 | NELog >> speciation [ 99 | "Return the speciation of the generation represented by the log" 100 | ^ speciation 101 | ] 102 | 103 | { #category : #'as yet unclassified' } 104 | NELog >> speciation: aSpeciation [ 105 | "Set the speciation" 106 | speciation := aSpeciation 107 | ] 108 | -------------------------------------------------------------------------------- /src/NEAT/NESpeciation.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NESpeciation, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'frameSize', 6 | 'groups' 7 | ], 8 | #category : #NEAT 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | NESpeciation >> frameSize: anInteger [ 13 | "Set the window frame size hyperparameter" 14 | frameSize := anInteger 15 | ] 16 | 17 | { #category : #'as yet unclassified' } 18 | NESpeciation >> groups [ 19 | "Return the groups of species. Each group being an instance of NESpecies" 20 | ^ groups 21 | ] 22 | 23 | { #category : #'as yet unclassified' } 24 | NESpeciation >> initialize [ 25 | super initialize. 26 | frameSize := 3. 27 | ] 28 | 29 | { #category : #'as yet unclassified' } 30 | NESpeciation >> numberOfSpecies [ 31 | "Return the number of species produced by the speciation" 32 | ^ groups size 33 | ] 34 | 35 | { #category : #'as yet unclassified' } 36 | NESpeciation >> process: someIndividuals [ 37 | "Run the speciation algorithm for a given collection of individuals. 38 | This method takes as argument a collection of collection of innovation numbers" 39 | | g | 40 | g := someIndividuals groupedBy: [ :individual | 41 | | seq | 42 | seq := individual innovationNumberSequence. 43 | seq size < 2 44 | ifTrue: [ seq first ] 45 | ifFalse: [ (seq last: (frameSize min: seq size - 1)) first ] ]. 46 | 47 | "Bind each species to its corresponding individuals" 48 | groups := g associations collect: [ :assoc | NESpecies new individuals: assoc value; id: assoc key ]. 49 | groups do: [ :aSpecies | 50 | aSpecies individuals do: [ :i | i species: aSpecies ] ] 51 | ] 52 | 53 | { #category : #'as yet unclassified' } 54 | NESpeciation >> visualize [ 55 | "Visualize groups of individual" 56 | | b legendBuilder | 57 | b := RTMondrian new. 58 | b shape box size: [ :s | s individuals size ]. 59 | b nodes: (self groups reverseSortedAs: #maxFitness). 60 | b layout grid. 61 | b normalizer normalizeColor: #maxFitness. 62 | b build. 63 | 64 | legendBuilder := RTLegendBuilder new. 65 | legendBuilder view: b view. 66 | legendBuilder addText: 'Species visualization'. 67 | legendBuilder addText: 'Box size = Species size'. 68 | legendBuilder addColorFadingFrom: Color gray to: Color red text: 'Max fitness'. 69 | legendBuilder build. 70 | ^ b view 71 | ] 72 | -------------------------------------------------------------------------------- /src/NEAT/NESpecies.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NESpecies, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'individuals', 6 | 'id' 7 | ], 8 | #category : #NEAT 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | NESpecies >> averageFitness [ 13 | "Return the average fitness of the species" 14 | ^ (self individuals collect: #fitness) average 15 | ] 16 | 17 | { #category : #'as yet unclassified' } 18 | NESpecies >> gtInspectorListOfIndividualIn: composite [ 19 | 20 | composite list 21 | title: 'Individuals'; 22 | display: individuals 23 | ] 24 | 25 | { #category : #'as yet unclassified' } 26 | NESpecies >> id [ 27 | "Return the identifier of the species" 28 | ^ id 29 | ] 30 | 31 | { #category : #'as yet unclassified' } 32 | NESpecies >> id: anInteger [ 33 | "Set the species identifier" 34 | id := anInteger 35 | ] 36 | 37 | { #category : #'as yet unclassified' } 38 | NESpecies >> individuals [ 39 | "Return the individuals composing the species" 40 | ^ individuals 41 | ] 42 | 43 | { #category : #'as yet unclassified' } 44 | NESpecies >> individuals: someIndividuals [ 45 | "Set the individuals of the species" 46 | individuals := someIndividuals 47 | ] 48 | 49 | { #category : #'as yet unclassified' } 50 | NESpecies >> maxFitness [ 51 | "Return the max fitness of the species individuals" 52 | ^ (self individuals collect: #fitness) max 53 | ] 54 | 55 | { #category : #'as yet unclassified' } 56 | NESpecies >> numberOfIndividuals [ 57 | "Return the size of the species" 58 | ^ individuals size 59 | ] 60 | -------------------------------------------------------------------------------- /src/NEAT/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #NEAT } 2 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlideSamples.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlideSamples, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-WsMetaHelper' 5 | } 6 | 7 | { #category : #accessing } 8 | SlideSamples >> slideMultiplePlaygrounds: aSlide [ 9 | 10 | ^ aSlide playground 11 | priority: 20; 12 | snippets: 13 | { 14 | '"Initialize ..." 15 | x := 42 16 | ' 17 | 18 | . 19 | 20 | '"Use the initialized value" 21 | y := x + 24 22 | ' 23 | 24 | 25 | } 26 | ] 27 | 28 | { #category : #accessing } 29 | SlideSamples >> slidePNG: aSlide [ 30 | 31 | 32 | | filename prio | 33 | filename := '2021-AI-General.014.png'. 34 | prio := 1.0140. 35 | ^ aSlide element 36 | priority: prio; 37 | element: [ 38 | | container form | 39 | form := PNGReadWriter formFromFileNamed: 40 | (self slidesDirectory / filename) fullName. 41 | form asElement asScalableElement constraintsDo: [ :c | 42 | c horizontal matchParent. 43 | c vertical matchParent ] ] 44 | ] 45 | 46 | { #category : #accessing } 47 | SlideSamples >> slideText: aSlide [ 48 | 49 | 50 | | prio cr tab | 51 | cr := Character cr asString. 52 | tab := Character tab asString. 53 | prio := 123. 54 | ^ aSlide text 55 | priority: prio; 56 | newTextWithFormat: (('Once upon a time... ',cr,'... there was a dragon.' )asRopedText 57 | glamorousRegularFont; 58 | fontSize: 50) 59 | ] 60 | 61 | { #category : #accessing } 62 | SlideSamples >> slideTitleAndPlayground: aSlide [ 63 | 64 | 65 | ^ aSlide labelAndElement 66 | priority: 1.0142; 67 | newFadedText: 'Perceptron for Metal Concert'; 68 | element: [ 69 | GtPlaygroundLiveSlide new 70 | newSnippet: 71 | 'perceptron := Neuron new step. 72 | perceptron weights: #( 2 6 2 ) . 73 | perceptron bias: 5 . 74 | ^ perceptron 75 | "Look at both the tabs ''Visual'' as well as ''Schematic'' "' ] 76 | ] 77 | 78 | { #category : #accessing } 79 | SlideSamples >> slidesDirectory [ 80 | 81 | ^ GtResourceReference path: 82 | Path * 'coentjo' / 'agile-ai-in-pharo' / 'slides' 83 | ] 84 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlidesForScripts07MatrixLibrarytxt.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlidesForScripts07MatrixLibrarytxt, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Scripts' 5 | } 6 | 7 | { #category : #accessing } 8 | SlidesForScripts07MatrixLibrarytxt >> scriptSnippetSlide02: aSlide [ 9 | 10 | 11 | ^ aSlide labelAndElement 12 | priority: 2; 13 | newFadedText: 'Example' ; 14 | element: [ 15 | GtPlaygroundLiveSlide new 16 | newSnippet: 17 | 'm := MMatrix newFromArrays: #(#(1 2 3) #(4 5 6)). 18 | m + m' 19 | ] 20 | ] 21 | 22 | { #category : #accessing } 23 | SlidesForScripts07MatrixLibrarytxt >> scriptSnippetSlide03: aSlide [ 24 | 25 | 26 | ^ aSlide labelAndElement 27 | priority: 3; 28 | newFadedText: 'Example' ; 29 | element: [ 30 | GtPlaygroundLiveSlide new 31 | newSnippet: 32 | 'n := 8. "Number of examples" 33 | din := 10. "Number of input values" 34 | h := 20. "Size of the hidden layer" 35 | dout := 5. "Number of output values" 36 | 37 | r := Random seed: 42. 38 | x := (MMatrix newRows: n columns: din) random: r. 39 | y := (MMatrix newRows: n columns: dout) random: r. 40 | w1 := (MMatrix newRows: din columns: h) random: r. 41 | w2 := (MMatrix newRows: h columns: dout) random: r. 42 | 43 | learningRate := 1e-6. 44 | losses := OrderedCollection new. 45 | 1500 timesRepeat: [ 46 | hh := x +* w1. 47 | hrelu := hh collect: [ :v | v max: 0 ]. 48 | ypred := hrelu +* w2. 49 | 50 | "Compute and print loss" 51 | loss := ((ypred - y) collect: [:vv | vv * vv ]) sum. 52 | losses add: loss. 53 | 54 | "Backprop to compute gradients of w2 and w2 with respect to loss" 55 | gradYPred := (ypred - y) * 2.0. 56 | gradW2 := hrelu transposed +* gradYPred. 57 | gradHRelu := gradYPred +* w2 transposed. 58 | gradH := gradHRelu collect: [ :v | v max: 0 ]. 59 | gradW1 := x transposed +* gradH. 60 | 61 | w1 := w1 - (gradW1 * learningRate). 62 | w2 := w2 - (gradW2 * learningRate) 63 | ]. 64 | 65 | g := RTGrapher new. 66 | d := RTData new. 67 | d noDot; connectColor: Color blue. 68 | d points: losses. 69 | d y: #yourself. 70 | g add: d. 71 | g axisX title: ''Epoch''. 72 | g axisY title: ''Error''. 73 | g' 74 | 75 | ] 76 | ] 77 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlidesForScripts08MatrixNNtxt.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlidesForScripts08MatrixNNtxt, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Scripts' 5 | } 6 | 7 | { #category : #accessing } 8 | SlidesForScripts08MatrixNNtxt >> scriptSnippetSlide02: aSlide [ 9 | 10 | 11 | ^ aSlide labelAndElement 12 | priority: 2; 13 | newFadedText: 'Example' ; 14 | element: [ 15 | GtPlaygroundLiveSlide new 16 | newSnippet: 17 | 18 | 'xor := #(#(0 0 0) 19 | #(0 1 1) 20 | #(1 0 1) 21 | #(1 1 0)). 22 | n := NMNetwork new. 23 | n configure: 2 hidden: 3 nbOfOutputs: 2. 24 | n train: xor nbEpochs: 5000. 25 | n predict: (MMatrix newFromVector: #(1 0)).' 26 | ] 27 | ] 28 | 29 | { #category : #accessing } 30 | SlidesForScripts08MatrixNNtxt >> scriptSnippetSlide03: aSlide [ 31 | 32 | 33 | ^ aSlide labelAndElement 34 | priority: 3; 35 | newFadedText: 'Example' ; 36 | element: [ 37 | GtPlaygroundLiveSlide new 38 | newSnippet: 39 | ' 40 | "The execution of this script initializes the variable irisData. 41 | This variable is used in the subsequent scripts of this chapter" 42 | irisCSV := (ZnEasy get: ''https://agileartificialintelligence.github.io/Datasets/iris.csv'') contents. 43 | lines := irisCSV lines. 44 | lines := lines allButFirst. 45 | tLines := lines collect: [ :l | 46 | | ss | 47 | ss := l substrings: '',''. 48 | (ss allButLast collect: [ :w | w asNumber ]), (Array with: ss 49 | last) ]. 50 | irisData := tLines collect: [ :row | |l| 51 | row last = ''setosa'' ifTrue: [ l := #( 0 ) ]. 52 | row last = ''versicolor'' ifTrue: [ l := #( 1 ) ]. 53 | row last = ''virginica'' ifTrue: [ l := #( 2 ) ]. 54 | row allButLast, l ]. 55 | irisData. 56 | 57 | n := NMNetwork new. 58 | n configure: 4 hidden: 6 nbOfOutputs: 3. 59 | n train: irisData nbEpochs: 3000. 60 | n' 61 | ] 62 | ] 63 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlidesForScripts13Robottxt.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlidesForScripts13Robottxt, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Scripts' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | SlidesForScripts13Robottxt >> scriptSnippetSlide02: aSlide [ 9 | 10 | 11 | ^ aSlide labelAndElement 12 | priority: 2; 13 | newFadedText: 'Example' ; 14 | element: [ 15 | GtPlaygroundLiveSlide new 16 | newSnippet: 17 | ' 18 | "We build a map with 80 wall blocks" 19 | map := GARobotMap new fillWithWalls: 80. 20 | 21 | "We build the robot" 22 | robot := GARobot new. 23 | "Make the robot lives in the map" 24 | robot map: map. 25 | 26 | 27 | g := GAEngine new. 28 | g endIfNoImprovementFor: 5. 29 | g numberOfGenes: 100. 30 | g populationSize: 250. 31 | "A gene value is a cardinal direction" 32 | g createGeneBlock: [ :rand :index :ind | #($N $S $W $E) atRandom: rand ]. 33 | 34 | "We want to minimize the distance between the robot and the exit" 35 | g minimizeComparator. 36 | g 37 | fitnessBlock: [ :genes | 38 | robot followOrders: genes. 39 | robot position dist: map exitPosition ]. 40 | g run. 41 | 42 | ' 43 | ] 44 | ] 45 | 46 | { #category : #'as yet unclassified' } 47 | SlidesForScripts13Robottxt >> scriptSnippetSlide03: aSlide [ 48 | 49 | 50 | ^ aSlide labelAndElement 51 | priority: 3; 52 | newFadedText: 'Example' ; 53 | element: [ 54 | GtPlaygroundLiveSlide new 55 | newSnippet: 56 | ' 57 | "We build a map with 80 wall blocks" 58 | map := GARobotMap new fillWithWalls: 80. 59 | 60 | "We build the robot" 61 | robot := GARobot new. 62 | "Make the robot lives in the map" 63 | robot map: map. 64 | 65 | 66 | g := GAEngine new. 67 | g endIfNoImprovementFor: 5. 68 | g numberOfGenes: 100. 69 | g populationSize: 250. 70 | "A gene value is a cardinal direction" 71 | g createGeneBlock: [ :rand :index :ind | #($N $S $W $E) atRandom: rand ]. 72 | 73 | "We want to minimize the distance between the robot and the exit" 74 | g minimizeComparator. 75 | g 76 | fitnessBlock: [ :genes | 77 | robot followOrders: genes. 78 | robot position dist: map exitPosition ]. 79 | g run. 80 | ... 81 | map drawRobotPath: (robot followOrders: g result). 82 | map open 83 | 84 | ' 85 | ] 86 | ] 87 | 88 | { #category : #'as yet unclassified' } 89 | SlidesForScripts13Robottxt >> scriptSnippetSlide04: aSlide [ 90 | 91 | 92 | ^ aSlide labelAndElement 93 | priority: 4; 94 | newFadedText: 'Example' ; 95 | element: [ 96 | GtPlaygroundLiveSlide new 97 | newSnippet: 98 | ' 99 | map := GARobotMap new fillWithWalls: 80. 100 | robot := GARobot new. 101 | robot map: map. 102 | g := GAEngine new. 103 | g endIfNoImprovementFor: 5. 104 | g numberOfGenes: 100. 105 | g populationSize: 250. 106 | g createGeneBlock: [ :rand :index :ind | #($N $S $W $E) atRandom: rand ]. 107 | g minimizeComparator. 108 | g 109 | fitnessBlock: [ :genes | 110 | | path penalty | 111 | path := robot followOrders: genes. 112 | penalty := path size / 2. 113 | (robot position dist: map exitPosition) + penalty ]. 114 | g run. 115 | map drawRobotPath: (robot followOrders: g result). 116 | map open 117 | ' 118 | ] 119 | ] 120 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlidesForScripts14Zoomorphictxt.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlidesForScripts14Zoomorphictxt, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Scripts' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | SlidesForScripts14Zoomorphictxt >> scriptSnippetSlide02: aSlide [ 9 | 10 | 11 | ^ aSlide labelAndElement 12 | priority: 2; 13 | newFadedText: 'Example' ; 14 | element: [ 15 | GtPlaygroundLiveSlide new 16 | newSnippet: 17 | ' 18 | creature := CCreature new configureBall: 10. 19 | c := CWorld new. 20 | c addCreature: creature. 21 | c open 22 | 23 | ' 24 | ] 25 | ] 26 | 27 | { #category : #accessing } 28 | SlidesForScripts14Zoomorphictxt >> scriptSnippetSlide03: aSlide [ 29 | 30 | 31 | ^ aSlide labelAndElement 32 | priority: 3; 33 | newFadedText: 'Example' ; 34 | element: [ 35 | GtPlaygroundLiveSlide new 36 | newSnippet: 37 | ' 38 | redCreature := CCreature new configureBall: 7. 39 | blueCreature := CCreature new color: Color blue; configureBall: 10. 40 | yellowCreature := CCreature new color: Color yellow; configureBall: 15. 41 | 42 | c := CWorld new. 43 | c addCreature: redCreature. 44 | c addCreature: blueCreature. 45 | c addCreature: yellowCreature. 46 | c open. 47 | blueCreature translateTo: 100 @ -50. 48 | yellowCreature translateTo: 200 @ -50. 49 | c open 50 | ' 51 | ] 52 | ] 53 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlidesForScripts15ZoomorphicSimulationtxt.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlidesForScripts15ZoomorphicSimulationtxt, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Scripts' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | SlidesForScripts15ZoomorphicSimulationtxt >> scriptSnippetSlide02: aSlide [ 9 | 10 | 11 | ^ aSlide labelAndElement 12 | priority: 2; 13 | newFadedText: 'Example' ; 14 | element: [ 15 | GtPlaygroundLiveSlide new 16 | newSnippet: 17 | ' 18 | creature := CCreature new configureBall: 10. 19 | creature materialize: #(24 34 0.46040109215788594 216 145 75 50 0.522318108469396 127 33 33 39 0.9105445367193523 70 93 30 88 0.5458242390378492 55 104 32 78 0.9326984656055917 36 74 20 38 0.23007194683890417 169 77 25 31 0.6407352956527543 219 147 28 14 0.5132012814205146 70 67 41 32 0.4101663086936652 116 21 30 53 0.4132064962215752 140 69 26 16 0.67239310366213 174 81 90 40 0.9493843137376868 77 82 90 24 0.9472498080773512 72 76 77 15 0.8207815849644977 51 46 63 21 0.23135899086546108 29 170 33 24 0.8508932494190025 70 94 34 32 0.85425589900662 192 99 83 84 0.8219266167338596 153 144 74 57 0.18008196523882541 38 136 76 82 0.4098378945513805 108 122 73 25 0.13200707016606214 72 102 11 24 0.525760215705149 60 33 34 53 0.47843877270279395 207 167 53 53 0.06064744597796698 47 203 90 90 0.3480303188869871 101 204 77 42 0.05166656036007524 143 155 67 89 0.5535930274164271 146 23 35 39 0.8390450097196945 136 143 78 87 0.955747404799679 153 71 15 84 0.9765097738460218 34 26 36 14 0.13894161191253998 78 51 38 41 0.1316714140594338 114 205 74 74 0.7760572821116342 191 32 67 61 0.08824125377379416 219 149 18 70 0.1469941007052521 169 175 39 43 0.2866080141424239 133 71 90 42 0.8735930218098653 90 85 53 21 0.18471918099313936 39 146 60 44 0.3135163908747567 120 38 57 43 0.32777994628892276 187 148 34 23 0.3158802803540045 35 102 75 42 0.1347404502354285 109 125 28 76 0.12238997760805766 64 23 68 70 0.9608936917180632 179 175 28 24 0.06067319378753807 116 196 ). 20 | c := CWorld new. 21 | c addCreature: creature. 22 | c open 23 | ' 24 | ] 25 | ] 26 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/SlidesForScripts17NEATtxt.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SlidesForScripts17NEATtxt, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Scripts' 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | SlidesForScripts17NEATtxt >> scriptSnippetSlide02: aSlide [ 9 | 10 | 11 | ^ aSlide labelAndElement 12 | priority: 2; 13 | newFadedText: 'Example' ; 14 | element: [ 15 | GtPlaygroundLiveSlide new 16 | newSnippet: 17 | ' 18 | dataset := #( #(0 0 0) #(0 1 1) #(1 0 1) #(1 1 0) ). 19 | 20 | neat := NEAT new. 21 | neat numberOfInputs: 2. 22 | neat numberOfOutputs: 1. 23 | neat fitness: [ :ind | 24 | | score | 25 | score := 0. 26 | dataset do: [ :tuple | 27 | diff := (ind evaluate: tuple allButLast) first - tuple last. 28 | score := score + (diff * diff) ]. 29 | (score / -4) asFloat ]. 30 | 31 | neat numberOfGenerations: 180. 32 | neat run. 33 | 34 | ' 35 | ] 36 | ] 37 | 38 | { #category : #'as yet unclassified' } 39 | SlidesForScripts17NEATtxt >> scriptSnippetSlide03: aSlide [ 40 | 41 | 42 | ^ aSlide labelAndElement 43 | priority: 3; 44 | newFadedText: 'Example' ; 45 | element: [ 46 | GtPlaygroundLiveSlide new 47 | newSnippet: 48 | ' 49 | "We prepare the data" 50 | irisCSV := (ZnEasy get: ''https://agileartificialintelligence.github.io/Datasets/iris.csv'') contents. 51 | lines := irisCSV lines. 52 | lines := lines allButFirst. 53 | tLines := lines collect: [ :l | 54 | | ss | 55 | ss := l substrings: '',''. 56 | (ss allButLast collect: [ :w | w asNumber ]), (Array with: ss last) ]. 57 | 58 | irisData := tLines collect: [ :row | 59 | | l | 60 | row last = ''setosa'' ifTrue: [ l := #( 0 ) ]. 61 | row last = ''versicolor'' ifTrue: [ l := #( 1 ) ]. 62 | row last = ''virginica'' ifTrue: [ l := #( 2 ) ]. 63 | row allButLast, l ]. 64 | 65 | "We run the NEAT algorithm" 66 | neat := NEAT new. 67 | neat numberOfInputs: 4. 68 | neat numberOfOutputs: 3. 69 | neat fitness: [ :ind | 70 | | score | 71 | score := 0. 72 | irisData do: [ :tuple | 73 | diff := (ind predict: tuple allButLast) - tuple last. 74 | score := score + (diff * diff) ]. 75 | (score / -4) asFloat ]. 76 | 77 | neat numberOfGenerations: 180. 78 | neat run. 79 | ' 80 | ] 81 | ] 82 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/WASlidesFinal.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #WASlidesFinal, 3 | #superclass : #WorkshopAI, 4 | #category : #'NeuralNetwork-GToolkit-Workshop' 5 | } 6 | 7 | { #category : #slides } 8 | WASlidesFinal >> slidePercep0980: aSlide [ 9 | 10 | 11 | ^ aSlide element 12 | priority: 1.0980; 13 | element: [ 14 | | form | 15 | form := PNGReadWriter formFromFileNamed: 16 | (GtResourceReference path: 17 | Path * 'coentjo' / 'agile-ai-in-pharo' / 'slides' 18 | / '2021-AI-General.098.png') fullName. 19 | form asElement asScalableElement constraintsDo: [ :c | 20 | c horizontal matchParent. 21 | c vertical matchParent ] ] 22 | ] 23 | 24 | { #category : #slides } 25 | WASlidesFinal >> slidePercep0990: aSlide [ 26 | 27 | 28 | ^ aSlide element 29 | priority: 1.0990; 30 | element: [ 31 | | form | 32 | form := PNGReadWriter formFromFileNamed: 33 | (GtResourceReference path: 34 | Path * 'coentjo' / 'agile-ai-in-pharo' / 'slides' 35 | / '2021-AI-General.099.png') fullName. 36 | form asElement asScalableElement constraintsDo: [ :c | 37 | c horizontal matchParent. 38 | c vertical matchParent ] ] 39 | ] 40 | 41 | { #category : #slides } 42 | WASlidesFinal >> slidePercep1000: aSlide [ 43 | 44 | 45 | ^ aSlide element 46 | priority: 1.1000; 47 | element: [ 48 | | form | 49 | form := PNGReadWriter formFromFileNamed: 50 | (GtResourceReference path: 51 | Path * 'coentjo' / 'agile-ai-in-pharo' / 'slides' 52 | / '2021-AI-General.100.png') fullName. 53 | form asElement asScalableElement constraintsDo: [ :c | 54 | c horizontal matchParent. 55 | c vertical matchParent ] ] 56 | ] 57 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/WorkshopAI.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #WorkshopAI, 3 | #superclass : #Object, 4 | #category : #'NeuralNetwork-GToolkit-Workshop' 5 | } 6 | 7 | { #category : #'helper methods' } 8 | WorkshopAI class >> aRandomNumber [ 9 | 10 | ^ 50 atRandom - 25 11 | ] 12 | 13 | { #category : #'helper methods' } 14 | WorkshopAI class >> showGraphInMorph: grapher [ 15 | "Probably deprecated on all sides ... :-( 16 | but does the job for this moment... " 17 | ^ GTInspector openOn: grapher 18 | ] 19 | 20 | { #category : #'helper methods' } 21 | WorkshopAI >> slide1For: aSlide [ 22 | 23 | "Rename this method to be more representative for your slide" 24 | ^ aSlide empty 25 | priority: 1. 26 | ] 27 | 28 | { #category : #'helper methods' } 29 | WorkshopAI >> slide: aSlide prio: prio fromPicture: filename [ 30 | 31 | ^ aSlide element 32 | priority: prio; 33 | element: [ 34 | | container form | 35 | form := PNGReadWriter formFromFileNamed: 36 | (self slidesDirectory / filename) fullName. 37 | form asElement asScalableElement constraintsDo: [ :c | 38 | c horizontal matchParent. 39 | c vertical matchParent ] ] 40 | ] 41 | 42 | { #category : #configuration } 43 | WorkshopAI >> slidesDirectory [ 44 | 45 | ^ GtResourceReference path: 46 | Path * 'coentjo' / 'agile-ai-in-pharo' / 'slides' 47 | ] 48 | -------------------------------------------------------------------------------- /src/NeuralNetwork-GToolkit/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'NeuralNetwork-GToolkit' } 2 | -------------------------------------------------------------------------------- /src/NeuralNetwork-Matrix/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #'NeuralNetwork-Matrix' } 2 | -------------------------------------------------------------------------------- /src/NeuralNetwork/ActivationFunction.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #ActivationFunction, 3 | #superclass : #Object, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | ActivationFunction >> derivative: output [ 9 | ^ self subclassResponsibility 10 | ] 11 | 12 | { #category : #'as yet unclassified' } 13 | ActivationFunction >> eval: z [ 14 | ^ self subclassResponsibility 15 | ] 16 | 17 | { #category : #accessing } 18 | ActivationFunction >> sayType [ 19 | self subclassResponsibility 20 | ] 21 | -------------------------------------------------------------------------------- /src/NeuralNetwork/InputPseudoLayer.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #InputPseudoLayer, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'children' 6 | ], 7 | #category : #'NeuralNetwork-NeuralNetwork' 8 | } 9 | 10 | { #category : #accessing } 11 | InputPseudoLayer >> children [ 12 | 13 | ^ children 14 | ] 15 | 16 | { #category : #accessing } 17 | InputPseudoLayer >> children: aChildrenCollection [ 18 | 19 | children := aChildrenCollection 20 | ] 21 | 22 | { #category : #accessing } 23 | InputPseudoLayer >> descriptiveLabel [ 24 | ^ 'Inputs' 25 | ] 26 | 27 | { #category : #accessing } 28 | InputPseudoLayer >> elementColor [ 29 | 30 | ^ Color darkGray 31 | ] 32 | 33 | { #category : #accessing } 34 | InputPseudoLayer >> elementSize [ 35 | ^ 10 @ 10 36 | ] 37 | 38 | { #category : #accessing } 39 | InputPseudoLayer >> neurons [ 40 | ^ self children 41 | ] 42 | -------------------------------------------------------------------------------- /src/NeuralNetwork/NNetworkTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NNetworkTest, 3 | #superclass : #TestCase, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #accessing } 8 | NNetworkTest >> testBasic [ 9 | 10 | | nnetwork | 11 | nnetwork := NNetwork new. 12 | nnetwork configure: 2 hidden: 2 nbOfOutputs: 1. 13 | self assert: ((nnetwork feed: #(1 3)) anyOne closeTo: 0.6745388083637036 precision: 0.0000000001). 14 | self assert: nnetwork numberOfOutputs equals: 1. 15 | ^ nnetwork 16 | ] 17 | 18 | { #category : #accessing } 19 | NNetworkTest >> testXOR [ 20 | 21 | | nnetwork | 22 | nnetwork := NNetwork new. 23 | nnetwork configure: 2 hidden: 3 nbOfOutputs: 1. 24 | 25 | 20000 timesRepeat: [ 26 | nnetwork train: #(0 0) desiredOutputs: #(0). 27 | nnetwork train: #(0 1) desiredOutputs: #(1). 28 | nnetwork train: #(1 0) desiredOutputs: #(1). 29 | nnetwork train: #(1 1) desiredOutputs: #(0). 30 | ]. 31 | 32 | self assert: (nnetwork feed: #(0 0)) first < 0.1. 33 | self assert: (nnetwork feed: #(0 1)) first > 0.9. 34 | self assert: (nnetwork feed: #(1 0)) first > 0.9. 35 | self assert: (nnetwork feed: #(1 1)) first < 0.1. 36 | ^nnetwork 37 | ] 38 | -------------------------------------------------------------------------------- /src/NeuralNetwork/NeuronLayerTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NeuronLayerTest, 3 | #superclass : #TestCase, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #accessing } 8 | NeuronLayerTest >> exampleBasic [ 9 | 10 | | nl result r | 11 | r := Random seed: 42. 12 | nl := NeuronLayer new. 13 | nl initializeNbOfNeurons: 3 nbOfWeights: 4 using: r. 14 | 15 | self assert: nl isOutputLayer. 16 | 17 | result := nl feed: #(1 2 3 4). 18 | self assert: result size equals: 3. 19 | result 20 | with: #(0.03700050130978758 0.9051275824569505 0.9815269659126287) 21 | do: [ :res :test | self assert: (res closeTo: test precision: 0.0000000001) ]. 22 | ^ nl 23 | ] 24 | 25 | { #category : #'as yet unclassified' } 26 | NeuronLayerTest >> testBasic [ 27 | | nl result r | 28 | r := Random seed: 42. 29 | nl := NeuronLayer new. 30 | nl initializeNbOfNeurons: 3 nbOfWeights: 4 using: r. 31 | 32 | self assert: nl isOutputLayer. 33 | 34 | result := nl feed: #(1 2 3 4). 35 | self assert: result size equals: 3. 36 | result 37 | with: #(0.03700050130978758 0.9051275824569505 0.9815269659126287) 38 | do: [ :res :test | self assert: (res closeTo: test precision: 0.0000000001) ] 39 | ] 40 | 41 | { #category : #'as yet unclassified' } 42 | NeuronLayerTest >> testOutputLayer [ 43 | | nl1 nl2 result random | 44 | random := Random seed: 42. 45 | nl1 := NeuronLayer new. 46 | nl1 initializeNbOfNeurons: 3 nbOfWeights: 4 using: random. 47 | nl2 := NeuronLayer new. 48 | nl2 initializeNbOfNeurons: 4 nbOfWeights: 3 using: random. 49 | nl1 nextLayer: nl2. 50 | self deny: nl1 isOutputLayer. 51 | self assert: nl2 isOutputLayer. 52 | result := nl1 feed: #(1 2 3 4). 53 | "Since nl2 has 4 neurons, we will obtain 4 outputs" 54 | self assert: result size equals: 4. 55 | result 56 | with: #(0.03089402289518759 0.9220488835263312 0.5200462953493654 0.20276557516858304) 57 | do: [ :r :test | self assert: (r closeTo: test precision: 0.0000000001) ] 58 | ] 59 | -------------------------------------------------------------------------------- /src/NeuralNetwork/NeuronTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NeuronTest, 3 | #superclass : #TestCase, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #accessing } 8 | NeuronTest >> exampleTrainingAND [ 9 | 10 | | p | 11 | p := Neuron new. 12 | p weights: #(-1 -1). 13 | p bias: 2. 14 | 15 | 5000 16 | timesRepeat: [ 17 | p train: #(0 0) desiredOutput: 0. 18 | p train: #(0 1) desiredOutput: 0. 19 | p train: #(1 0) desiredOutput: 0. 20 | p train: #(1 1) desiredOutput: 1 ]. 21 | " 22 | self assert: ((p feed: #(0 0)) closeTo: 0 precision: 0.1). 23 | self assert: ((p feed: #(0 1)) closeTo: 0 precision: 0.1). 24 | self assert: ((p feed: #(1 0)) closeTo: 0 precision: 0.1). 25 | self assert: ((p feed: #(1 1)) closeTo: 1 precision: 0.1). 26 | " 27 | ^ p 28 | ] 29 | 30 | { #category : #accessing } 31 | NeuronTest >> exampleTrainingOR [ 32 | 33 | | p | 34 | p := Neuron new. 35 | p weights: #(-1 -1). 36 | p bias: 2. 37 | 38 | 5000 39 | timesRepeat: [ 40 | p train: #(0 0) desiredOutput: 0. 41 | p train: #(0 1) desiredOutput: 1. 42 | p train: #(1 0) desiredOutput: 1. 43 | p train: #(1 1) desiredOutput: 1 ]. 44 | 45 | " self assert: ((p feed: #(0 0)) closeTo: 0 precision: 0.1). 46 | self assert: ((p feed: #(0 1)) closeTo: 1 precision: 0.1). 47 | self assert: ((p feed: #(1 0)) closeTo: 1 precision: 0.1). 48 | self assert: ((p feed: #(1 1)) closeTo: 1 precision: 0.1)." 49 | ^ p 50 | ] 51 | 52 | { #category : #accessing } 53 | NeuronTest >> newMap [ 54 | 55 | | aWardleyMap | 56 | 57 | aWardleyMap := GtWardleyMapModel new. 58 | self assert: aWardleyMap nodes isEmpty. 59 | ^ aWardleyMap 60 | ] 61 | 62 | { #category : #'as yet unclassified' } 63 | NeuronTest >> testTrainingAND [ 64 | | p | 65 | p := Neuron new. 66 | p weights: #(-1 -1). 67 | p bias: 2. 68 | 69 | 5000 70 | timesRepeat: [ 71 | p train: #(0 0) desiredOutput: 0. 72 | p train: #(0 1) desiredOutput: 0. 73 | p train: #(1 0) desiredOutput: 0. 74 | p train: #(1 1) desiredOutput: 1 ]. 75 | 76 | self assert: ((p feed: #(0 0)) closeTo: 0 precision: 0.1). 77 | self assert: ((p feed: #(0 1)) closeTo: 0 precision: 0.1). 78 | self assert: ((p feed: #(1 0)) closeTo: 0 precision: 0.1). 79 | self assert: ((p feed: #(1 1)) closeTo: 1 precision: 0.1). 80 | ] 81 | 82 | { #category : #'as yet unclassified' } 83 | NeuronTest >> testTrainingOR [ 84 | | p | 85 | p := Neuron new. 86 | p weights: #(-1 -1). 87 | p bias: 2. 88 | 89 | 5000 90 | timesRepeat: [ 91 | p train: #(0 0) desiredOutput: 0. 92 | p train: #(0 1) desiredOutput: 1. 93 | p train: #(1 0) desiredOutput: 1. 94 | p train: #(1 1) desiredOutput: 1 ]. 95 | 96 | self assert: ((p feed: #(0 0)) closeTo: 0 precision: 0.1). 97 | self assert: ((p feed: #(0 1)) closeTo: 1 precision: 0.1). 98 | self assert: ((p feed: #(1 0)) closeTo: 1 precision: 0.1). 99 | self assert: ((p feed: #(1 1)) closeTo: 1 precision: 0.1). 100 | ] 101 | -------------------------------------------------------------------------------- /src/NeuralNetwork/Normalization.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #Normalization, 3 | #superclass : #Object, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | Normalization >> normalizeData: aCollectionOfTrainingDataWithExpectedOutput [ 9 | "Normalize the data provided as argument" 10 | 11 | | nbOfColumns min max | 12 | "We exclude the expected output" 13 | nbOfColumns := aCollectionOfTrainingDataWithExpectedOutput first size - 1. 14 | 15 | min := OrderedCollection new. 16 | max := OrderedCollection new. 17 | 1 to: nbOfColumns do: [ :index | 18 | | column | 19 | column := aCollectionOfTrainingDataWithExpectedOutput collect: [ :row | row at: index ]. 20 | min add: column min. 21 | max add: column max ]. 22 | 23 | ^ self normalizeData: aCollectionOfTrainingDataWithExpectedOutput min: min max: max 24 | ] 25 | 26 | { #category : #'as yet unclassified' } 27 | Normalization >> normalizeData: aCollectionOfTrainingDataWithExpectedOutput min: minimumValues max: maximumValues [ 28 | | nbOfColumns result mn mx | 29 | nbOfColumns := aCollectionOfTrainingDataWithExpectedOutput first size - 1. 30 | 31 | result := OrderedCollection new. 32 | aCollectionOfTrainingDataWithExpectedOutput do: [ :row | 33 | | t v | 34 | t := OrderedCollection new. 35 | 1 to: nbOfColumns do: [ :index | 36 | v := row at: index. 37 | mn := minimumValues at: index. 38 | mx := maximumValues at: index. 39 | t add: ((v - mn) / (mx - mn)) asFloat 40 | ]. 41 | t add: row last. 42 | result add: t asArray ]. 43 | ^ result asArray 44 | ] 45 | -------------------------------------------------------------------------------- /src/NeuralNetwork/NormalizationTest.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NormalizationTest, 3 | #superclass : #TestCase, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | NormalizationTest >> testEmptyError [ 9 | self should: [ Normalization new normalizeData: #() ] raise: Error. 10 | ] 11 | 12 | { #category : #'as yet unclassified' } 13 | NormalizationTest >> testError [ 14 | self should: [ Normalization new normalizeData: #( #(10 5 1) ) ] raise: Error. 15 | 16 | ] 17 | 18 | { #category : #'as yet unclassified' } 19 | NormalizationTest >> testSimpleNormalization [ 20 | | input expectedNormalizedInput | 21 | input := #( #(10 5 1) #(2 6 0) ). 22 | expectedNormalizedInput := Normalization new normalizeData: input. 23 | self assert: expectedNormalizedInput equals: #(#(1.0 0.0 1) #(0.0 1.0 0)) 24 | ] 25 | -------------------------------------------------------------------------------- /src/NeuralNetwork/Perceptron.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #Perceptron, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'weights', 6 | 'bias' 7 | ], 8 | #category : #'NeuralNetwork-NeuralNetwork' 9 | } 10 | 11 | { #category : #accessing } 12 | Perceptron >> bias [ 13 | 14 | ^ bias 15 | ] 16 | 17 | { #category : #accessing } 18 | Perceptron >> bias: aNumber [ 19 | bias := aNumber 20 | ] 21 | 22 | { #category : #accessing } 23 | Perceptron >> feed: inputs [ 24 | 25 | | z | 26 | z := (inputs with: weights collect: [ :x :w | x * w ]) sum + bias. 27 | ^ z > 0 28 | ifTrue: [ 1 ] 29 | ifFalse: [ 0 ] 30 | ] 31 | 32 | { #category : #accessing } 33 | Perceptron >> weights [ 34 | ^ weights 35 | ] 36 | 37 | { #category : #accessing } 38 | Perceptron >> weights: someWeightsAsNumber [ 39 | "Set the weights of the neuron. 40 | Take a collection of numbers as argument." 41 | weights := someWeightsAsNumber 42 | ] 43 | -------------------------------------------------------------------------------- /src/NeuralNetwork/SigmoidAF.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #SigmoidAF, 3 | #superclass : #ActivationFunction, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | SigmoidAF >> derivative: output [ 9 | ^ output * (1 - output) 10 | ] 11 | 12 | { #category : #'as yet unclassified' } 13 | SigmoidAF >> eval: z [ 14 | ^ 1 / (1 + z negated exp) 15 | ] 16 | 17 | { #category : #accessing } 18 | SigmoidAF >> sayType [ 19 | ^ 'Neuron' 20 | ] 21 | -------------------------------------------------------------------------------- /src/NeuralNetwork/StepAF.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #StepAF, 3 | #superclass : #ActivationFunction, 4 | #category : #NeuralNetwork 5 | } 6 | 7 | { #category : #'as yet unclassified' } 8 | StepAF >> derivative: output [ 9 | ^ 1 10 | ] 11 | 12 | { #category : #accessing } 13 | StepAF >> eval: z [ 14 | ^ z > 0 15 | ifTrue: [ 1 ] 16 | ifFalse: [ 0 ] 17 | ] 18 | 19 | { #category : #accessing } 20 | StepAF >> sayType [ 21 | ^ 'Perceptron' 22 | ] 23 | -------------------------------------------------------------------------------- /src/NeuralNetwork/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #NeuralNetwork } 2 | -------------------------------------------------------------------------------- /src/NeuralTutorial/NeuralNetworkTutorial.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #NeuralNetworkTutorial, 3 | #superclass : #AbstractTutorial, 4 | #category : #NeuralTutorial 5 | } 6 | 7 | { #category : #tutorial } 8 | NeuralNetworkTutorial >> tutorial [ 9 | "ProfStef goOn: NeuralNetworkTutorial " 10 | ^ #( welcome welcome2 welcome3 ) 11 | ] 12 | 13 | { #category : #lessons } 14 | NeuralNetworkTutorial >> welcome [ 15 | ^ Lesson 16 | title: 'Welcome' 17 | lesson: 18 | '"Hello! This is an introduction in Neural Networks. 19 | 20 | We start by looking at a Perceptron " 21 | 22 | ProfStef next.' 23 | ] 24 | 25 | { #category : #lessons } 26 | NeuralNetworkTutorial >> welcome2 [ 27 | ^ Lesson 28 | title: 'Welcome2' 29 | lesson: 30 | '"Hello! This is an introduction in Neural Networks. 31 | 32 | We start by looking at a Perceptron " 33 | 34 | ProfStef next.' 35 | ] 36 | 37 | { #category : #lessons } 38 | NeuralNetworkTutorial >> welcome3 [ 39 | ^ Lesson 40 | title: 'Welcome3' 41 | lesson: 42 | '"Hello! This is an introduction in Neural Networks. 43 | 44 | We start by looking at a Perceptron " 45 | 46 | ProfStef next.' 47 | ] 48 | -------------------------------------------------------------------------------- /src/NeuralTutorial/NeuralNetworkTutorialTest.class.st: -------------------------------------------------------------------------------- 1 | " 2 | A NeuralNetworkTutorialTest is a test class for testing the behavior of NeuralNetworkTutorial 3 | " 4 | Class { 5 | #name : #NeuralNetworkTutorialTest, 6 | #superclass : #TestCase, 7 | #category : #NeuralTutorial 8 | } 9 | 10 | { #category : #tests } 11 | NeuralNetworkTutorialTest >> testTutorial [ 12 | ProfStef goOn: NeuralNetworkTutorial . 13 | 14 | ] 15 | -------------------------------------------------------------------------------- /src/NeuralTutorial/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #NeuralTutorial } 2 | -------------------------------------------------------------------------------- /src/Robot/GARobot.class.st: -------------------------------------------------------------------------------- 1 | Class { 2 | #name : #GARobot, 3 | #superclass : #Object, 4 | #instVars : [ 5 | 'position', 6 | 'map' 7 | ], 8 | #category : #Robot 9 | } 10 | 11 | { #category : #'as yet unclassified' } 12 | GARobot >> followOrders: orders [ 13 | "Make the robot follow the orders. 14 | Return the path taken by the robot" 15 | | delta possiblePosition path | 16 | delta := { $N -> (0 @ -1) . $S -> (0 @ 1) . 17 | $W -> (-1 @ 0) . $E -> (1 @ 0) } asDictionary. 18 | path := OrderedCollection new. 19 | path add: map initialPosition. 20 | self position: map initialPosition. 21 | orders 22 | do: [ :direction | 23 | possiblePosition := position + (delta at: direction). 24 | 25 | "If we found the exit, then we return and 26 | make no further progresses" 27 | possiblePosition == map exitPosition ifTrue: [ ^ path ]. 28 | 29 | "If there is no wall, then we effectively do the move" 30 | (map gridAt: possiblePosition) ~= #wall ifTrue: [ 31 | position := possiblePosition. 32 | path add: position ] ]. 33 | ^ path 34 | ] 35 | 36 | { #category : #'as yet unclassified' } 37 | GARobot >> map: aMap [ 38 | "Set the map where the robot lives in" 39 | map := aMap 40 | ] 41 | 42 | { #category : #'as yet unclassified' } 43 | GARobot >> position [ 44 | "Return the position of the robot" 45 | ^ position 46 | ] 47 | 48 | { #category : #'as yet unclassified' } 49 | GARobot >> position: aPoint [ 50 | "Set the position of the robot" 51 | position := aPoint 52 | ] 53 | -------------------------------------------------------------------------------- /src/Robot/package.st: -------------------------------------------------------------------------------- 1 | Package { #name : #Robot } 2 | --------------------------------------------------------------------------------