text:
# **Behavioral Cloning**
---

**Behavioral Cloning Project**

The goals / steps of this project are the following:
* Use the simulator to collect data of good driving behavior
* Build, a convolution neural network in Keras that predicts steering angles from images
* Train and validate the model with a training and validation set
* Test that the model successfully drives around track one without leaving the road
* Summarize the results with a written report

[//]: # (Image References)

[image1]: ./model.png "Model Visualization"
[image2]: ./sample.png "Normal Image"
[image3]: ./flippedsample.png "Flipped Image"

## Rubric Points
### Here I will consider the [rubric points](https://review.udacity.com/#!/rubrics/432/view) individually and describe how I addressed each point in my implementation.

---
### Files Submitted & Code Quality

#### 1. Submission includes all required files and can be used to run the simulator in autonomous mode

My project includes the following files:
* model.py containing the script to create and train the model
* drive.py for driving the car in autonomous mode
* model.h5 containing a trained convolution neural network
* writeup_report.md or writeup_report.pdf summarizing the results

#### 2. Submission includes functional code
Using the Udacity provided simulator and my drive.py file, the car can be driven autonomously around the track by executing
```sh
python drive.py model.h5
```

#### 3. Submission code is usable and readable

The model.py file contains the code for training and saving the convolution neural network. The file shows the pipeline I used for training and validating the model, and it contains comments to explain how the code works.

### Model Architecture and Training Strategy

#### 1. An appropriate model architecture has been employed

My model is based on the Nvidia model. It consists two initial layers to crop and normalize the image data. Then, 5 convolutional layers that activate with elu and run through batch normalization. Finally, the model runs through 4 fully connected layers, including the final output layer, with the elu activation and batch normalization after each layer. The code can be found in `model.py` (line 17 - 73).
~~~
def network():
    # Nvidia Model
    model = Sequential()

    model.add(Cropping2D(cropping=((60,30), (0,0)), input_shape=(160, 160, 3)))

    model.add(Lambda(lambda x: (x / 127.5) - 1))

    # First Convolutional Layer
    model.add(Conv2D(nb_filter = 24, nb_row = 5, nb_col = 5, subsample = (2, 2)))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Second Convolutional Layer
    model.add(Conv2D(nb_filter = 36, nb_row = 5, nb_col = 5, subsample = (2, 2)))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Third Convolutional Layer
    model.add(Conv2D(nb_filter = 48, nb_row = 5, nb_col = 5, subsample = (2, 2)))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Fourth Convolutional Layer
    model.add(Conv2D(nb_filter = 64, nb_row = 3, nb_col = 3, subsample = (1, 1)))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Fifth Convolutional Layer
    model.add(Conv2D(nb_filter = 64, nb_row = 3, nb_col = 3, subsample = (1, 1)))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    model.add(Flatten())

    # First Fully Connected Layer
    model.add(Dense(100))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Second Fully Connected Layer
    model.add(Dense(50))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Third Fully Connected Layer
    model.add(Dense(10))
    model.add(Activation('elu'))
    model.add(BatchNormalization())

    # Output
    model.add(Dense(1))

    # Choose optimizer and loss
    model.compile(loss = 'mse', optimizer= 'adam')

    return model

~~~

#### 2. Attempts to reduce overfitting in the model

The model uses batch normalization which has a slight regularization effect since it adds noises to the hidden layers. Thus, batch normalization helps us avoid overfitting.

#### 3. Model parameter tuning

The model used an adam optimizer, so the learning rate was not tuned manually `model.py` (line 71). As I train the network at 2 epochs and then 5 epochs, I found that the loss keeps decreasing. So eventually I increased it to 10 and got the model to drive correctly.

#### 4. Appropriate training data

Training data was chosen to keep the vehicle driving on the road. I used a combination of center lane driving, recovering from the left and right sides of the road, flipped center image to eliminate left turn bias.

For details about how I created the training data, see the next section.

### Model Architecture and Training Strategy

#### 1. Solution Design Approach

The overall strategy for deriving a model architecture was to use the Nvidia model as the baseline, and then I tweaked the parameters of the network like the shape of the layers to work with my data. Specifically, the Nvidia model takes input of shape 66x200x3, but I changed it to 160x160x3.

Then I added a Keras cropping layer to focus the model on the road. To combat overfitting and help with convergence, I used batch normalization after each hidden layer. I also chose to use `elu` activation function as it is very easy to use and avoid the problems of `relu`.

In order to gauge how well the model was working, I split my image and steering angle data into a training and validation set. The Nvidia tweaks worked well at first when I trained with a small sample of the data (about 300 samples) and 2 epochs. The car was running off track at this point.

Then I ran on the full data set at 2 epochs. And the car did really well but still ran off track at the mid way point.

I then trained with 5 epochs and 10 epochs. At 5 epochs, the car still ran off the road, but I noticed that all 5 epochs saw the accuracy increasing. Thus, I increased the number of epochs and eventually got the car to drive correctly.

#### 2. Final Model Architecture

Here is a visualization of the architecture (note: visualizing the architecture is optional according to the project rubric)

![alt text][image1]

#### 3. Creation of the Training Set & Training Process

I used sample data from Udacity only.

To augment the data set, I also flipped images and angles in order to eliminate left-turn bias, since the sample data only runs on track 1. For example, here is an image that has then been flipped:

![alt text][image2] ![alt text][image3]

I also use the left and right camera images and apply a correction factor to help the model recover from the curb.

After the collection and augmentation process, I had 32140 number of data points. I then preprocessed this data by halving the width of the images, in order to reduce the input space, note that I also add this resize step to `drive.py` to input correct data into the model.

I finally randomly shuffled the data set and put 20% of the data into a validation set.

I used this training data for training the model. The validation set helped determine if the model was over or under fitting.

repository: buiducanh/behavioral-cloning

repo_name: buiducanh/behavioral-cloning


text:
# DSTC Track 4: SIMMC | Sub-Task #3: Multimodal Dialog State Tracking (MM-DST)

This directory contains the code and the scripts for running the baseline models for Sub-Task #3: Multimodal DST.

The Multimodal Dialog State Tracking (MM-DST) task involves systematically tracking the attributes of dialog act labels cumulative across multiple turns.
Multimodal belief states at each turn should encode sufficient information for handling user utterances in the downstream dialog components (e.g. Dialog Policy).

Please check the [task input](./TASK_INPUTS.md) file for a full description of inputs
for each subtask.

For more details on the task definition and the baseline models we provide, please refer to our SIMMC paper:
```
@article{moon2020situated,
  title={Situated and Interactive Multimodal Conversations},
  author={Moon, Seungwhan and Kottur, Satwik and Crook, Paul A and De, Ankita and Poddar, Shivani and Levin, Theodore and Whitney, David and Difranco, Daniel and Beirami, Ahmad and Cho, Eunjoon and Subba, Rajen and Geramifard, Alborz},
  journal={arXiv preprint arXiv:2006.01460},
  year={2020}
}
```
**NOTE**: The [paper][simmc_arxiv] reports the results from an earlier version of the dataset and with different train-dev-test splits, hence the baseline performances on the challenge resources will be slightly different.

## Installation (Same across all sub-tasks)

* Git clone the repository:
```
$ git lfs install
$ git clone https://github.com/facebookresearch/simmc.git
```

* Install the required Python packages:
  * [Python 3.6+](https://www.python.org/downloads/)
  * [PyTorch 1.5+](https://pytorch.org/get-started/locally/#start-locally)
  * [Transformers](https://huggingface.co/transformers/installation.html)

**NOTE**: We recommend installation in a virtual environment ([user guide](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)). Create a new virtual environment and activate it prior to installing the packages.

## Run Baselines

### Baseline: GPT-2 Based DST

1. **Preprocess** the datasets to reformat the data for GPT-2 input.

```
$ cd mm_dst
$ ./run_preprocess_gpt2.sh
```

The shell script above repeats the following for all {train|dev|devtest} splits and both {furniture|fashion} domains.

```
$ python -m gpt2_dst.scripts.preprocess_input \
    --input_path_json={path_dir}/data/simmc-fashion/fashion_train_dials.json \
    --output_path_predict={path_dir}/mm_dst/gpt2_dst/data/fashion/fashion_train_dials_predict.txt \
    --output_path_target={path_dir}/mm_dst/gpt2_dst/data/fashion/fashion_train_dials_target.txt \
    --output_path_special_tokens={path_dir}/mm_dst/gpt2_dst/data/fashion/special_tokens.json
    --len_context=2 \
    --use_multimodal_contexts=1 \
```

2. **Train** the baseline model

```
$ ./run_train_gpt2.sh
```

The shell script above repeats the following for both {furniture|fashion} domains.

```
$ python -m gpt2_dst.scripts.run_language_modeling \
    --output_dir={path_dir}/save/fashion \
    --model_type=gpt2 \
    --model_name_or_path=gpt2 \
    --line_by_line \
    --add_special_tokens={path_dir}/mm_dst/gpt2_dst/data/fashion/special_tokens.json \
    --do_train \
    --train_data_file={path_dir}/mm_dst/gpt2_dst/data/fashion/fashion_train_dials_target.txt \
    --do_eval \
    --eval_data_file={path_dir}/mm_dst/gpt2_dst/data/fashion/fashion_dev_dials_target.txt \
    --num_train_epochs=1 \
    --overwrite_output_dir \
    --per_gpu_train_batch_size=4 \
    --per_gpu_eval_batch_size=4 \
    #--no_cuda

```

3. **Generate** prediction for `devtest` data

```
$ ./run_generate_gpt2.sh
```

The shell script above repeats the following for both {furniture|fashion} domains.
```
$ python -m gpt2_dst.scripts.run_generation \
    --model_type=gpt2 \
    --model_name_or_path={path_dir}/mm_dst/gpt2_dst/save/furniture/ \
    --num_return_sequences=1 \
    --length=100 \
    --stop_token='<EOS>' \
    --prompts_from_file={path_dir}/mm_dst/gpt2_dst/data/furniture/furniture_devtest_dials_predict.txt \
    --path_output={path_dir}/mm_dst/gpt2_dst/results/furniture/furniture_devtest_dials_predicted.txt
```

Here is an example output:
```
System : Yes, here's another one you might like. User : Oh yeah I think my niece would really like that. Does it come in any other colors?  System : I'm sorry I don't have that information. User : Ah well. I like this color. I'd like to go ahead and buy it. Can you add it to my cart please?  => Belief State :
 DA:INFORM:PREFER:JACKET  [ fashion-O_2  = obj ] DA:REQUEST:ADD_TO_CART:JACKET  [ fashion-O_2  = obj ] <EOB>  Of course, you now have this
```

The generation results are saved in the `/mm_dst/results` folder. Change the `path_output` to a desired path accordingly.

4. **Evaluate** predictions for `devtest` data

```
$ ./run_evaluate_gpt2.sh
```

The shell script above repeats the following for both {furniture|fashion} domains.
```
python -m gpt2_dst.scripts.evaluate \
    --input_path_target={path_dir}/mm_dst/gpt2_dst/data/furniture/furniture_devtest_dials_target.txt \
    --input_path_predicted={path_dir}/mm_dst/gpt2_dst/results/furniture/furniture_devtest_dials_predicted.txt \
    --output_path_report={path_dir}/mm_dst/gpt2_dst/results/furniture/furniture_devtest_dials_report.json

```

Evaluation reports are saved in the `/mm_dst/results` folder as JSON files.

*Important*: For any of the models you build, please make sure that you use the function `simmc.mm_dst.utils.evaluate_dst.evaluate_from_flat_list` to obtain the evaluation reports.

Please also note that the GPT2 fine-tuning is highly sensitive to the batch size (which `n_gpu` of your machine may affect), hence it may need some hyperparameter tuning to obtain the best results (and avoid over/under fitting). Please feel free to change the hyperparameter of the default settings (provided) to compare results.

Below is the summary of the [published models](https://github.com/facebookresearch/simmc/releases/download/1.0/mm_dst_gpt2_baselines.tar.gz) we provide:

| Baseline | Dialog Act F1 | Slot F1 |
|--------|-------|-------|
| GPT2 - Furniture (text-only) | 69.9 | 52.5 |
| GPT2 - Furniture (multimodal) | 69.5 | 63.9 |
| GPT2 - Fashion (text-only) | 61.2 | 52.1 |
| GPT2 - Fashion (multimodal) | 61.1 | 60.6 |

## Rules for Sub-task #3 Submissions
* Disallowed input per each turn: `belief_state`, `system_transcript`, `system_transcript_annotated`, `state_graph_1`, `state_graph_2`, and anything from future turns.
* If you would like to use any other external resources, please consult with the track organizers (simmc@fb.com). Generally, we allow the use of publicly available pre-trained language models, such as BERT, GPT-2, etc.

[dstc9]:https://sites.google.com/dstc.community/dstc9/home
[simmc_arxiv]:https://arxiv.org/abs/2006.01460

license: MIT

repository: inkoon/simmc

branch_name: refs/heads/master

extension: md

gha_language: Python

gha_license_id: MIT

license_type: permissive

repo_name: inkoon/simmc


text:
---
layout: post
title: "HTTP saves time, saves money, saves you"
date: 2011-09-21 10:33
comments: true
categories: [http]
alias: "/384/http-saves-time-saves-money-saves-you"
---

It Italy, as usual, our govern is a mess when talking about *{insert any topic here}*: today's topic will be... **webservices, saving money, time and providing an efficient service to the citizens**.
<!-- more -->

## Veryfing a VAT number

A requirement in your projects could be to verify, when a user subscribes to your service, which is intended for business owners, his VAT number.

The italian govern has such a service in the form of a [webpage](http://www1.agenziaentrate.it/servizi/vies/vies.htm), thus thought for humans: they don't offer a specific webservice but that's not a problem, as I can submit the form ( it uses GET, which is exactly meant for the purpose ) with an HTTP request. Cool.

## Doing HTTP wrong

So the first thing that came to my mind was to use cURL to verify the service:

``` bash
curl -I -X GET http://www1.agenziaentrate.it/servizi/vies/transazione.htm -d "s=IT&p=02524130305" -G
```

where `s` is the country of the company and `p` its VAT number (bare in mind that the VAT number used here is wrong, as it was the one of my first company, now closed).

 Oh, wow, `200 OK`.

## Why is this so bad?

At first glance, it seemed weird to me, but I tought that they, for some reasons, considered my old company's VAT number still valid, but then I realized **how much noob an entire IT department can be** so I started suspecting that the system was **responding 200 to every request**.

Guess what, I was right.

I repeated the cURL call omitting the `-I` option (retrieve headers only) and saw the entire response body: in a table, beautiful as the sun, `VAT number not found`.

So, if I need to verify the existence of a VAT number with the tools provided by my govern, I need to **parse an entire HTML document**, **look for a DOM element** ( `table#feedback > td` and stuff like that ), **parse the resulting string** and... oh, I'm already annoyed by describing the steps to do it!

Take a look at the pseudo-code for this implementation:

```
vat = request.get('vat')
vatVerifyService = new ItalianGovernVatService

vatResponse = vatVerifyService.check(vat)

if (vatResponse) {
  body = varResponse.getBody()

  // parse the body
  // look for a DOM attribute,
  // which will change as they update the website with a new fancy markup
  // then evaluate the resulting string
}
```

and your code if you keep HTTP in consideration:

```
vat = request.get('vat')
vatVerifyService = new ItalianGovernVatService

vatResponse = vatVerifyService.check(vat)
// vatResponse.getCode() tells you if the VAT is good or not
```

Ok, this resource is not intended to be a *machine-consumed* service but:

* using the proper HTTP status code would have saved my time
* using the proper HTTP status code helps you expose a resource that, in some cases like this one, can be useful to both human-beings and computer programs, without writing any line of code, thus without wasting money

Adapt your resources and domain application protocols to HTTP: this is the only way to save your and your consumers' money and time in the modern web.

branch_name: refs/heads/source

extension: markdown

gha_language: JavaScript


text:
# GANs galore! 🕵♂🦹♂
A collection of GANs for experimentation and study implemented with PyTorch

> This repo is a simple collection of GAN varieties to explore the possibilities of this model type.
> The models are set up to train on commom toy (image) datasets. The plan ist to eventually include
> time-series data to make this useful for work.

## Design principles
- Use pytorch-lightning and hydra for clean and modern model architectures
- Build a model hierarchiy to reuse as much code as possible between variants

repository: cwerner/gans-galore

repo_name: cwerner/gans-galore


text:
fwknopf Cookbook
================
cookbook for fwknop

Requirements
------------

#### Operating System
Tested on Debian, should work on RHEL/CentOS

#### packages
- `sysctl` - for enabling ip forwarding

Attributes
----------
TODO: List your cookbook attributes here.

e.g.
#### fwknop::server

    Key
    Type
    Description
    Default

    <tt>['fwknop-cookbook']['site']</tt>
    String
    The site name (e.g. 'site23') - use 'test' for testing
    <tt>true</tt>

    <tt>['fwknop-cookbook']['server']</tt>
    String
    The server to connect to
    <tt>true</tt>

Usage
-----
#### fwknop-cookbook::server

Contributing
------------
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.

e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github

License and Authors
-------------------
Authors: TODO: List authors

repository: yakara-ltd/fwknop-cookbook

repo_name: yakara-ltd/fwknop-cookbook


text:
# Docker Build Environment
A simple docker container, which provides a build environment to build software in PRs welcome!

## What's this?
This docker containers containing all the stuff I needed to build my own projects, but it is intended to provide a set of useful build tools in this containers in order to provide a nice docker container for CI builds.

## How to add software

1. Open a PR and add the software to the Docker file (if it does not break anything else)
2. Make your own Docker image based upon this (`FROM lmmdock/build-environment`)

repository: lmm-git/docker-build-environment

repo_name: lmm-git/docker-build-environment


text:
Barron
------

Barron provides a Ruby API and simple command-line interface
for checking locks on a given system. Currently it uses filesystem
locks, but eventually a system-wide configurable setup would be
ideal.

Barron can check for a lock, or wait until a resource becomes
free.

``` bash
barron my-resource # Will return success if available, or an error code if locked elsewhere
barron my-resource --block # Will wait until the resource becomes free
```

You can check locks on those same resources in Ruby:

``` ruby
class MyClass
  # You can call `Barron.lock` directly,
  # or include the method into your namespace.
  include Barron

  def my_work

    lock "my-resource", block: false do
      # This will only run if the resource
      # is free when `lock` is called.
    end

    lock "my-resource" do
      # `lock` will wait until the resource
      # is free, then perform this work.
    end

  end
end
```

--
**Installation**

``` bash
gem install barron
```

And you're done!

--
**Additional Info**

Barron is licensed under the MIT License.

[Robert Barron](http://en.wikipedia.org/wiki/Robert_Barron_(locksmith\)) invented the double–acting tumbler lock in 1778.

Written by Matthew Beale (matt.beale@madhatted.com).

repository: mixonic/barron

repo_name: mixonic/barron