Merge branch 'microsoft:main' into main
This commit is contained in:
commit
4328eacd64
File diff suppressed because one or more lines are too long
|
|
@ -6,21 +6,12 @@ Lab Assignment from [AI for Beginners Curriculum](https://github.com/microsoft/a
|
|||
|
||||
Solve two classification problems using single- and multi-layered fully-connected networks using PyTorch or TensorFlow:
|
||||
|
||||
1. Iris classification problem
|
||||
1. MNIST handwritten digit classification problem
|
||||
1. **[Iris classification](https://en.wikipedia.org/wiki/Iris_flower_data_set)** problem - an example of problem with tabular input data, which can be handled by classical machine learning. You goal would be to classify irises into 3 classes, based on 4 numeric parameters.
|
||||
1. **MNIST** handwritten digit classification problem which we have seen before.
|
||||
|
||||
Try different network architectures to achieve the best accuracy you can get.
|
||||
|
||||
|
||||
## Stating Notebook
|
||||
|
||||
Start the lab by opening [MyFW_MNIST.ipynb](MyFW_MNIST.ipynb)
|
||||
Start the lab by opening [LabFrameworks.ipynb](LabFrameworks.ipynb)
|
||||
|
||||
## Questions
|
||||
|
||||
As a result of this lab, try to answer the following questions:
|
||||
|
||||
- Does the inter-layer activation function affect network performance?
|
||||
- Do we need 2- or 3-layered network for this task?
|
||||
- Did you experience any problems training the network? Especially as the number of layers increased.
|
||||
- How do weights of the network behave during training? You may plot max abs value of weights vs. epoch to understand the relation.
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ As an example, let's look at the architecture of VGG-16, a network that achieved
|
|||
|
||||
[**Often Used CNN Architectures**](CNN_Architectures.md)
|
||||
|
||||
## [Lab](lab/README.md)
|
||||
|
||||
In the lab, you are tasked with classification of different cats and dogs breeds. Images are more complex than MNIST dataset and of higher dimensions, and there are more than 10 classes.
|
||||
## CNNs for Other Tasks
|
||||
|
||||
While CNNs are most often used for Computer Vision tasks, they are generally good for extracting fix-sized patterns. For example, if we are dealing with sounds, we may also want to use CNNs to look for some specific patterns in audio signal - in which case filters would be 1-dimensional (and this CNN would be called 1D-CNN). Also, sometimes 3D-CNN is used to extract features in multi-dimensional space, such as certain events occurring on video - CNN can capture certain patterns of feature changing over time.
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,31 @@
|
|||
# Classification of Pets Faces
|
||||
|
||||
Lab Assignment from [AI for Beginners Curriculum](https://github.com/microsoft/ai-for-beginners).
|
||||
|
||||
## Task
|
||||
|
||||
Imagine you need to develop and application for pet nursery to catalog all pets. One of the great features of such an application would be automatically discovering the breed from a photograph. This can be successfully done using neural networks.
|
||||
|
||||
You need to train a convolutional neural network to classify different breeds of cats and dogs using **Pet Faces** dataset.
|
||||
|
||||
## The Dataset
|
||||
|
||||
We will use the **Pet Faces** dataset, derived from [Oxford-IIIT](https://www.robots.ox.ac.uk/~vgg/data/pets/) pets dataset. It contains 35 different breeds of dogs and cats.
|
||||
|
||||

|
||||
|
||||
To download the dataset, use this code snippet:
|
||||
|
||||
```python
|
||||
!wget https://mslearntensorflowlp.blob.core.windows.net/data/petfaces.tar.gz
|
||||
!tar xfz petfaces.tar.gz
|
||||
!rm petfaces.tar.gz
|
||||
```
|
||||
|
||||
## Stating Notebook
|
||||
|
||||
Start the lab by opening [PetFaces.ipynb](PetFaces.ipynb)
|
||||
|
||||
## Takeaway
|
||||
|
||||
You have solved a relatively complex problem of image classification from scratch! There were quite a lot of classes, and you were still able to get reasonable accuracy! It also makes sense to measure top-k accuracy, because it is easy to confuse some of the classes which are not clearly different even to human beings.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 634 KiB |
|
|
@ -29,3 +29,7 @@ Let's see transfer learning in action in corresponding notebooks:
|
|||
* [Transfer Learning - PyTorch](TransferLearningPyTorch.ipynb)
|
||||
* [Transfer Learning - TensorFlow](TransferLearningTF.ipynb)
|
||||
|
||||
## [Lab](lab/README.md)
|
||||
|
||||
In this lab, we will use real-life [Oxford-IIIT](https://www.robots.ox.ac.uk/~vgg/data/pets/) pets dataset with 35 breeds of cats and dogs, and we will build a transfer learning classifier.
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,29 @@
|
|||
# Classification of Oxford Pets using Transfer Learning
|
||||
|
||||
Lab Assignment from [AI for Beginners Curriculum](https://github.com/microsoft/ai-for-beginners).
|
||||
|
||||
## Task
|
||||
|
||||
Imagine you need to develop and application for pet nursery to catalog all pets. One of the great features of such an application would be automatically discovering the breed from a photograph. In this assignment, we will use transfer learning to classify real-life pet images from [Oxford-IIIT](https://www.robots.ox.ac.uk/~vgg/data/pets/) pets dataset.
|
||||
|
||||
## The Dataset
|
||||
|
||||
We will use the original [Oxford-IIIT](https://www.robots.ox.ac.uk/~vgg/data/pets/) pets dataset, which contains 35 different breeds of dogs and cats.
|
||||
|
||||
To download the dataset, use this code snippet:
|
||||
|
||||
```python
|
||||
!wget https://mslearntensorflowlp.blob.core.windows.net/data/oxpets_images.tar.gz
|
||||
!tar xfz oxpets_images.tar.gz
|
||||
!rm oxpets_images.tar.gz
|
||||
```
|
||||
|
||||
## Stating Notebook
|
||||
|
||||
Start the lab by opening [OxfordPets.ipynb](OxfordPets.ipynb)
|
||||
|
||||
|
||||
## Takeaway
|
||||
|
||||
Transfer learning and pre-trained networks allow us to solve real-world image classification problems relatively easily. However, pre-trained networks work well on images of similar kind, and if we start classifying very different images (eg. medical images), we are likely to get much worse results.
|
||||
|
||||
|
|
@ -23,4 +23,108 @@ Multi-agent systems are nowadays used in a number of applications:
|
|||
* In systems modeling, multi-agent approach is used to simulate the behavior of a complex model. For example, multi-agent approach has been successfully used to predict the spread of COVID-19 disease worldwide. Similar approach can be used to model traffic in the city, and see how it reacts to changes in traffic rules.
|
||||
* In complex automation systems, each device can act as an independent agent, which makes the whole system less monolith and more robust.
|
||||
|
||||
## NetLogo
|
||||
We will not spend a lot of time going deep into multi-agent systems, but consider one example of **Multi-Agent Modeling**.
|
||||
## NetLogo
|
||||
|
||||
[NetLogo](https://ccl.northwestern.edu/netlogo/) is a multi-agent modeling environment based on modified [Logo](https://en.wikipedia.org/wiki/Logo_(programming_language)) programming language. This language was developed for teaching programming concepts to kids, and it allows you to control an agent called **turtle**, which can move, leaving a trace behind. This allows creating complex geometric figures, which is a very visual way to understand the behavior of an agent.
|
||||
|
||||
In NetLogo, we can create many turtles by using the `create-turtles` command. We can then command all turtles to do some actions (in the example below - more 10 point forward):
|
||||
|
||||
```
|
||||
create-turtles 10
|
||||
ask turtles [
|
||||
forward 10
|
||||
]
|
||||
```
|
||||
|
||||
Of course, it is not interesting when all turtles do the same thing, so we can `ask` groups of turtles, eg. those who are in vicinity of a certain point. We can also create turtles of different *breeds* using `breed [cats cat]` command. Here `cat` is the name of a breed, and we need to specify both singular and plural word, because different commands use different forms for clarity.
|
||||
|
||||
We will not go into learning NetLogo language - you can visit brilliant [Beginner's Interactive NetLogo Dictionary](https://ccl.northwestern.edu/netlogo/bind/) resource if you are interested to learn more.
|
||||
|
||||
You can [download](https://ccl.northwestern.edu/netlogo/download.shtml) and install NetLogo to try it.
|
||||
|
||||
### Model's Library
|
||||
|
||||
A great thing about NetLogo is that it contains a great library of working models that you can try. Go to **File → Models Library**, and you have many categories of models to chose from.
|
||||
|
||||
<img alt="NetLogo Models Library" src="images/NetLogo-ModelLib.png" width="60%"/>
|
||||
|
||||
You can open one of the models, for example **Biology → Flocking**.
|
||||
|
||||
### Main Principles
|
||||
|
||||
After opening the model, you are taken to the main NetLogo screen. Here is a sample model that describes the population of wolves and sheep, given finite resources (grass).
|
||||
|
||||

|
||||
|
||||
On this screen, you can see:
|
||||
|
||||
* **Interface** section, which contains:
|
||||
- Main field, where all agents live
|
||||
- Different controls: buttons, sliders, etc.
|
||||
- Graphs that you can use to display parameters of the simulation
|
||||
* **Code** tab contains the editor, where you can type NetLogo program
|
||||
|
||||
In most cases, interface would have **Setup** button, which initializes the simulation state, and **Go** button that starts execution. Those are handled by corresponding handlers in the code that look like this:
|
||||
|
||||
```
|
||||
to go [
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
NetLogo world consist of the following objects:
|
||||
|
||||
* **Agents** (turtles) that can move across the field and do something. You command agents by using `ask turtles [...]` syntax, and the code in brackets is executed by all agents in *turtle mode*.
|
||||
* **Patches** are square areas of the field, on which agents live. You can refer to all agents on the same patch, or you can change patch colors and some other properties. You can also `ask patches` to do something.
|
||||
* **Observer** is a unique one agent that controls the world. All button handlers are executed in *observer mode*.
|
||||
|
||||
> The beauty of multi-agent environment is that the code that runs in turtle mode or in patch mode is executed at the same time by all agents in parallel. Thus, by writing a little code and programming the behavior of individual agent, you can create complex behavior of the simulation system as a whole.
|
||||
|
||||
### Flocking
|
||||
|
||||
As an example of multi-agent behavior, let's consider **[Flocking](https://en.wikipedia.org/wiki/Flocking_(behavior))** - a complex pattern that is very similar to how flocks of birds fly. Watching them fly you can think that they follow some kind of collective algorithm, or that they possess some form of *collective intelligence*. However, this complex behavior arises when each individual agent (*bird*)only observes some other agents in a short distance from it, and follows three simple rules:
|
||||
|
||||
* **Alignment** - it steers towards the average heading of neighboring agents
|
||||
* **Cohesion** - it tries to steer towards the average position of neighbors (*long range attraction*)
|
||||
* **Separation** - when getting too close to other birds, it tries to move away (*short range repulsion*)
|
||||
|
||||
You can run flocking example and observe the behavior. You can also adjust parameters, such as *degree of separation*, or the *viewing range*, which defines how far each bird can see. Note that if you decrease viewing range to 0, all birds become blind, and flocking stops. If you decrease separation to 0, all birds gather into a straight line.
|
||||
|
||||
Try to switch to **Code** tab and see where three rules of flocking (alignment, cohesion and separation) are implemented in code. Note how we refer only to those agents that are in sight.
|
||||
|
||||
### Other Models to see
|
||||
|
||||
There are a few interesting models that I encourage you to experiment with:
|
||||
* **Art → Fireworks** shows how a firework can be considered a collective behavior of individual fire streams
|
||||
* **Social Science → Traffic Basic** and **Social Science → Traffic Grid** show the model of city traffic in 1D and 2D Grid with or without traffic lights. Each car in the simulation follows the simple rules:
|
||||
- If the space in front of it is empty - accelerate (up to a certain max speed)
|
||||
- If it sees the obstacle in front - brake (and you can adjust how far a driver can see)
|
||||
* **Social Science → Party** shows how people group together during a cocktail party. You can find the combination of parameters that lead to the fastest increase of happiness of the group.
|
||||
|
||||
As you can see from those examples, multi-agent simulations can be quite a useful way to understand the behavior of a complex system consisting of individuals that follow the same or similar logic. It can also be used to control virtual agents, such as [NPCs](https://en.wikipedia.org/wiki/NPC) in computer games, or agents in 3D animated worlds.
|
||||
|
||||
## Deliberative Agents
|
||||
|
||||
Agents above were typically very simple, reacting to changes in environment using some kind of algorithm - **reactive agents**. However, sometimes agents can reason and plan their action, in which case they are called **deliberative**.
|
||||
|
||||
A typical example would be a personal agent that receives an instructions from human to book a vacation tour. Suppose that there are many agents that live on the internet, who can help it. It should then contact other agents to see which flights are available, what are the hotel prices for different dates, and try to negotiate the best price. When the vacation plan is complete and confirmed by the owner, it can proceed with booking.
|
||||
|
||||
In order to do that, agents need to **communicate**. And for successful communication they need:
|
||||
|
||||
* Some **standard languages to exchange knowledge**, such as [Knowledge Interchange Format](https://en.wikipedia.org/wiki/Knowledge_Interchange_Format) (KIF) and [Knowledge Query and Manipulation Language](https://en.wikipedia.org/wiki/Knowledge_Query_and_Manipulation_Language) (KQML). Those languages are designed based on [Speech Act theory](https://en.wikipedia.org/wiki/Speech_act).
|
||||
* Those languages should also include some **protocols for negotiations**, based on different **auction types**.
|
||||
* A **common ontology** to use, so that they refer to the same concepts knowing their semantics
|
||||
* A way to **discover** what different agents can do, also based on some sort of ontology
|
||||
|
||||
Deliberative agents are much more complex than reactive, because they do not only react to changes in environment, they should also be able to *intiate* actions. One of the proposed architectures for deliberative agents is so-called Belief-Desire-Intention (BDI):
|
||||
|
||||
* **Beliefs** form a set of knowledge about environment that the agent has. It can be structures as knowledgebase or set of rules that an agent can apply to a specific situation in the environment.
|
||||
* **Desires** define what agents wants to do, i.e. its goals. For example, the goal of the personal assistant agent above is to book a tour, and the goal of hotel agent is to maximize profit.
|
||||
* **Intentions** are specific actions that agent plans to achieve its goals. Actions typically change the environment and cause communication with other agents.
|
||||
|
||||
There are some platforms available for building multi-agent systems, such as [JADE](https://jade.tilab.com/). [This paper](https://arxiv.org/ftp/arxiv/papers/2007/2007.08961.pdf) contains fairly recent review of multi-agent platforms, together with brief history of multi-agent systems the their different usage scenarios.
|
||||
|
||||
## Takeaway
|
||||
|
||||
Multi-Agent systems can take very different forms and be used in many different applications. One common thing between them is focusing on simpler behavior of an individual agent, and achieving more complex behavior of the overall system due to **synergetic effect**.
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
|
|
@ -53,14 +53,15 @@ For a gentle introduction to *AI in the Cloud* topic you may consider taking the
|
|||
<td>Intro to Frameworks (PyTorch/TensorFlow)<br/>Overfitting</td>
|
||||
<td><a href="3-NeuralNetworks/05-Frameworks/README.md">Text</a><br/><a href="3-NeuralNetworks/05-Frameworks/Overfitting.md">Text</a></td>
|
||||
<td><a href="3-NeuralNetworks/05-Frameworks/IntroPyTorch.ipynb">PyTorch</td>
|
||||
<td><a href="3-NeuralNetworks/05-Frameworks/IntroKerasTF.md">Keras/TensorFlow</td><td></td></tr>
|
||||
<td><a href="3-NeuralNetworks/05-Frameworks/IntroKerasTF.md">Keras/TensorFlow</td>
|
||||
<td><a href="3-NeuralNetworks/05-Frameworks/lab/README.md">Lab</a></td></tr>
|
||||
<tr><td>IV</td><td colspan="2"><b><a href="4-ComputerVision/README.md">Computer Vision</a></b></td>
|
||||
<td><a href="https://docs.microsoft.com/learn/modules/intro-computer-vision-pytorch/?WT.mc_id=academic-33554-dmitryso">MS Learn</a></td>
|
||||
<td><a href="https://docs.microsoft.com/learn/modules/intro-computer-vision-TensorFlow/?WT.mc_id=academic-33554-dmitryso">MS Learn</a></td>
|
||||
<td>PAT</td></tr>
|
||||
<tr><td>6</td><td>Intro to Computer Vision. OpenCV</td><td>Text<td colspan="2">Notebook</td><td></td></tr>
|
||||
<tr><td>7</td><td>Convolutional Neural Networks<br/>CNN Architectures</td><td><a href="4-ComputerVision/07-ConvNets/README.md">Text</a><br/><a href="4-ComputerVision/07-ConvNets/CNN_Architectures.md">Text</a></td><td><a href="4-ComputerVision/07-ConvNets/ConvNetsPyTorch.ipynb">PyTorch</a></td><td><a href="4-ComputerVision/07-ConvNets/ConvNetsTF.ipynb">TensorFlow</a></td><td></td></tr>
|
||||
<tr><td>8</td><td>Pre-trained Networks and Transfer Learning<br/>Training Tricks</td><td><a href="4-ComputerVision/08-TransferLearning/README.md">Text</a><br/><a href="4-ComputerVision/08-TransferLearning/TrainingTricks.md">Text</a></td><td><a href="4-ComputerVision/08-TransferLearning/TransferLearningPyTorch.ipynb">PyTorch</a></td><td><a href="4-ComputerVision/08-TransferLearning/TransferLearningTF.ipynb">TensorFlow</a><br/><a href="4-ComputerVision/08-TransferLearning/Dropout.ipynb">Dropout sample</a></td><td></td></tr>
|
||||
<tr><td>7</td><td>Convolutional Neural Networks<br/>CNN Architectures</td><td><a href="4-ComputerVision/07-ConvNets/README.md">Text</a><br/><a href="4-ComputerVision/07-ConvNets/CNN_Architectures.md">Text</a></td><td><a href="4-ComputerVision/07-ConvNets/ConvNetsPyTorch.ipynb">PyTorch</a></td><td><a href="4-ComputerVision/07-ConvNets/ConvNetsTF.ipynb">TensorFlow</a></td><td><a href="4-ComputerVision/07-ConvNets/lab/README.md">Lab</a></td></tr>
|
||||
<tr><td>8</td><td>Pre-trained Networks and Transfer Learning<br/>Training Tricks</td><td><a href="4-ComputerVision/08-TransferLearning/README.md">Text</a><br/><a href="4-ComputerVision/08-TransferLearning/TrainingTricks.md">Text</a></td><td><a href="4-ComputerVision/08-TransferLearning/TransferLearningPyTorch.ipynb">PyTorch</a></td><td><a href="4-ComputerVision/08-TransferLearning/TransferLearningTF.ipynb">TensorFlow</a><br/><a href="4-ComputerVision/08-TransferLearning/Dropout.ipynb">Dropout sample</a></td><td><a href="4-ComputerVision/08-TransferLearning/lab/README.md">Lab</a></td></tr>
|
||||
<tr><td>9</td><td>Autoencoders and VAEs</td><td><a href="4-ComputerVision/09-Autoencoders/README.md">Text</a></td><td>PyTorch</td><td><a href="4-ComputerVision/09-Autoencoders/AutoencodersTF.ipynb">TensorFlow</a></td><td></td></tr>
|
||||
<tr><td>10</td><td>Generative Adversarial Networks</td><td><a href="4-ComputerVision/10-GANs/README.md">Text</a></td><td>PyTorch</td><td><a href="4-ComputerVision/10-GANs/GANs.ipynb">TensorFlow</a></td><td></td></tr>
|
||||
<tr><td>11</td><td>Object Detection</td><td>Text</td><td>PyTorch</td><td>TensorFlow</td><td></td></tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue