# A dive into the many faces of manifolds

What are manifolds? I started down this rabbit hole because of Chris Colah’s excellent Neural Networks / Functional programming blog post:

At their crudest, types in computer science are a way of embedding some kind of data in n bits. Similarly, representations in deep learning are a way to embed a data manifold in n dimensions.

So the problem is that people talk about them even when you don’t think you need to care about topology, or even really know what topology means.

The following is a bit of a dive into examples of manifolds with the intention of better understanding what a manifold is.

## Starting somewhere

Opening quote from Wikipedia:

In mathematics, a manifold is a topological space that locally resembles Euclidean space near each point.

Without knowing exactly what topological and Euclidean spaces are that’s hard to understand. Let’s try simple Wikipedia:

A manifold is a concept from mathematics. Making a manifold is like making a flat map of a sphere (the Earth).

A ball (sphere plus interior) is a 3-manifold with boundary. Its boundary is a sphere, a 2-manifold.

So, to me, this makes no sense of creating a manifold (a flat map) from a manifold (a sphere is a 2-manifold). Why create a manifold if you’ve already got one? (My thinking here is wrong, but I’m trying to explain all my incorrect thinking as I go and clear it up at the end)

### Bounds checking

Some kind of useful quotes from the section on boundaries:

A piece of paper is a 2-manifold with a 1-manifold boundary (a line)

A ball is a 3-manifold with a 2-manifold boundary (a sphere)

## Show me the money

‘Simple’ examples are usually the way for me out of confusion. The list of manifolds helps a lot:

1. $\mathbb{R}^n$ are all manifolds, so a line $\mathbb{R}$ is a 1-manifold
2. A x,y 2D plane $\mathbb{R}^2$ is a 2-manifold
3. All spheres $\mathbb{S}^n$ are manifolds… stop there, I’m confused

### Spheres

This really gets me. Why do we need to create maps of the world if it’s already a manifold. The simple Wikipedia explanation makes sense, i.e. it’s obvious that we want to create a flat map of the world. It also makes sense that where as a triangle on the globe doesn’t add up to 180 degrees (bad) does nicely add up to 180 degrees on a flat map (good). But why, if the earth is already a manifold do we want to create another manifold from that. Isn’t being a manifold good enough? Some people are never satisfied.

### n-manifold

A sphere is a 2-manifold, so although it is a 3D object, close to any one point it looks like a 2D grid.

The important part is the n-manifold. This is what cleared it up for me, you don’t care about creating one manifold from another.

An n-manifold resembles the nth dimension near one point. So a flat map is a 2-manifold and the earth is a 2-manifold because they both represent a 2D grid near one point.

### Manifold Hypothesis

In another post from Chris Colah, he talks explicitly about manifolds. But he talks about them assuming that you know what they are:

The manifold hypothesis is that natural data forms lower-dimensional manifolds in its embedding space.

`*scream*`

### Nash equilibria

Although John Nash is most famous for his Nash equilibrium, but it a lot of his most important work was to do with manifolds:

His famous work on the existence of smooth isometric embeddings of Riemannian manifolds into Euclidean space.

### Differentiation

Interestingly differentiating a curve at a point on that curve gives you the slope of the flat line at that point. So there’s a connection between differentiation and manifolds.

There’s a Calculus on Manifolds book that looks interesting, taken from this talk on The simple essence of automatic differentiation. Then there is a link back to Chris Olah’s NN/FP post based on this Conal Elliot’s Automatic Differentiation paper.

## Euclid forgive me

To be honest even Euclidean space gets me confused. That’s basically just $\mathbb{R}^n$ which I can understand better. But is there a specific reason for using Euclidean? Is there some extra property of Euclidean space that isn’t inherent in $\mathbb{R}^n$? There’s a fundamental principle of parallel lines not converging in Euclidean space, but then if a manifold is in Euclidean space, how can a sphere be a manifold? It doesn’t explain why we want to convert one manifold into another (as in the spheres section above), or even really know what topology means.

### Euclid’s grid

I keep thinking of Euclidean space as basically everything. But it’s not – it’s a n-dimensional grid (with infinite points as it’s the real number line in each direction) and it has straight edges. So a ball isn’t in Euclidean space, or “isn’t Euclidean”, I’m not sure which.

In image analysis applications, one can consider images as functions
on the Euclidean space (plane), sampled on a grid

### Data manifolds (back to Chris)

Perhaps data manifolds are the structure of the data. For example as above an image data is a 2D Euclidean grid.

They get referred to in the MIT CS231n CNNs course when talking about ReLUs:

(-) Unfortunately, ReLU units can be fragile during training and can “die”. For example, a large gradient flowing through a ReLU neuron could cause the weights to update in such a way that the neuron will never activate on any datapoint again. If this happens, then the gradient flowing through the unit will forever be zero from that point on. That is, the ReLU units can irreversibly die during training since they can get knocked off the data manifold. For example, you may find that as much as 40% of your network can be “dead” (i.e. neurons that never activate across the entire training dataset) if the learning rate is set too high. With a proper setting of the learning rate this is less frequently an issue.

It’s as if data manifold is the useful/accessible part of the data.

### What’s not Euclidean

For instance, in social networks,
the characteristics of users can be modeled as signals on the
vertices of the social graph [22]. Sensor networks are graph
models of distributed interconnected sensors, whose readings
are modelled as time-dependent signals on the vertices.

In computer graphics and vision, 3D objects are
modeled as Riemannian manifolds (surfaces) endowed with
properties such as color texture.

Manifolds don’t have to Euclidean! But at one particular point on a manifold surface it is approximately a grid in the local area. So this holds if it is Euclidian, because locally on a sheet of paper it’s Euclidean as the sheet of paper is already Euclidean.

But certainly I like the explanation that 3D graphics are manifolds. So there’s nothing special that makes the earth a manifold it’s just one example of one. So I think this means that any 3D shape is a manifold.

So what’s not Euclidean and not a manifold?

### What’s not a manifold?

That dear reader… is an exercise for you.

## What did this get us?

1. Euclidean space means a grid (duh)
2. An image of pixels is a 2D grid – possibly the data manifold that Chris Olah was referring to
3. A 3D graphic (or the earth) is a 2-manifold. These are not Euclidean but are 2D Euclidean (grid shaped) close to a point on their surface
4. When your data is 3D graphics – that is your data manifold

# Self-driving cars should first replace amateur instead of professional drivers

Professional drivers, i.e. lorry, bus and taxi drivers are under threat from being replaced by computers. Whilst amateur drivers, all the rest of us, feel no pressure to stop.

I want to lay out the reasons why this is backwards. Amateur drivers should be replaced, whilst professional drivers should have their skills augmented.

Once we reach a level of self driving automation where no humans are needed then this piece is no longer relevant, but there is a lot of scope to avoid human deaths before we reach that point.

The trolley problem is not the issue, the drunken humans who think its fun to go racing the trolleys are the problem.

This gets long, feel free to skip ahead to a section. This is based on a European centric view point, most specifically UK and Belgian roads.

## Professional vs amateur

Lorry, taxi and bus drivers are professional drivers. They do it for their living. People pay them to drive.

Lorry drivers are paid because they can reliably and safely deliver large amounts of goods over long distances. Billions of euros, every year.

Bus drivers are responsible for transporting 10 – 50 people around each journey. When you consider the value of the cargo, either in human terms or in absolute money (\$5m per person) the responsibility is huge.

Taxi drivers are effectively looking after multi-million dollar cargo. They also have vast local knowledge. A special case of this is the ‘knowledge’ that London taxi drivers must pass. Much of this local knowledge is rendered less important by GPS systems, but still the GPS augments the driver’s knowledge.

These professional drivers, drive all day and in all conditions. They have well maintained cars, and make full use of the cars rather than the cars sitting in garages doing nothing.

Professional drivers are the gold standard of driving styles.

Everyone who is not a paid to drive full time is simply an amateur one. They typically drive for the economic benefit (time saving) or convenience/freedom of having a car.

They typically have people in the car who are personally more valuable than taxi passengers as they are likely family or close friends. But the contrast is that they do not think in these terms. They put a sticker ‘baby on board’ in the back window and assume that will solve the problem.

## Level 3 automation

The current level of self-driving for cars such as Tesla and GM, is level 3. This is where the car can drive but requires constant supervision. This flies in the face of two issues:

1. Humans are good at vision but bad at concentration
2. Computers are bad at vision but good at concentration

With passive level 2 systems in a car, the human uses their vision and the car concentrates for extreme circumstances. Further it helps the human concentration because it keeps them constantly engaged.

With active level 3 systems, the computer is relied on for its bad vision and the human is no longer constantly engaged but expected to keep their bad concentration.

Further there is a major issue of doubt / delayed reactions. With level 2 systems, if the car detects it is about to crash, it does not doubt the outcome and reacts faster than a human could. With level 3 systems if the human detects that the car is about to crash they are in doubt if the computer will avoid a crash and so delay before doing anything.

## Safety

Buses in Belgium are 80% safer than cars (0.4 deaths vs 2 deaths per million passenger miles in 2015). But the figure for cars looks better than it is because it includes taxis. Taxis are do many more miles than amateur drivers and are less likely to crash.

In fact the number of bus crashes are so low that we can almost look at the individual cases for the bus crashes. Also note that a single bus crash can kill up to 30 people, so the number of deadly accidents is even fewer.

Lorry, buses and taxis drive more safely. They avoid all the typical causes of crashes:

• Alcohol
• Tiredness
• Texting
• Calling
• Speeding
• Going through red lights
• Driving erratically
• Having poor eye sight
• Driving too close
• Not changing driving style to bad weather conditions
• Calmness in an accident
• Driving without insurance
• Driving without a licence

Tiredness can be an issue for lorry drivers, but there are strict rules. Automated cars also have these attributes but they don’t have human level performance to handle all situations.

This safety of passengers is the potential route to ending traffic deaths. Once you can look at individual crashes similar as with air crashes then the cause of the crash can be properly understood and recorded. When the number is so many as now aggregate statistics have to be used which will never get the number of deaths down to zero.

Professional drivers can be augmented by the automated driving. Each crash can be analysed and added to the training for the automated car. This means that automated cars will have more knowledge in extreme cases but less in every day. On top of that automated cars can react quicker and without emotion to handle a car that is out of control. Automated systems can be taught to drive at the very limit of the frictional ability of the tires combined with weather conditions.

## Drinking, texting, calling, dozing, tail gating

These are the fundamental problems of amateur drivers. Whilst they are warned about the consequences, the chances are always very low of having an accident so there is always the temptation to drive when incapacitated in some way. There is no standard test that can be enforced on drivers before starting. There is some efforts to put in breathalysers in cars, but the chances are so low that these changes will not get to zero deaths. The only stories I have heard about this are repeat drink-drive offenders and taxi drivers. But this still only stops one aspect, drinking. All the other failures of human drivers have no acceptable solutions.

## Crash vs accident

When trying to focus on the cost of human life vs the cost of professional drivers, the language needs to change to focus on that practically all crashes are avoidable, they are not accidents.

From this CityLab article when talking about road deaths framing it in terms of crashes rather than accidents gives focus to the causes. Each crash should be treated in terms of an air crash. There are no air accidents, and to get down to zero road deaths, there can be no accidents. An accident isn’t necessarily avoidable, but a crash is.

## Bus crashes

Aspects of bus crashes in Belgium are down to single figure deaths per year. When the figures are this low we can consider each case individually. These are some of the causes:

• Driver become unwell such as a heart attack
• A tyre blows out on a motorway cross over and drives off the side

Both these cases would be better handled with automated assistance.

If the driver takes their hands off the wheel the computer can take over and bring the bus to a stop at the side of the road.

If an extreme event such as a tyre blow out or hitting a large patch of ice, the computer is able to be better trained. Simulations can be replayed millions of times and the raw physics of these situations can be well analysed.

## Solve all bus crashes

Each of the situations that caused a fatal bus crash can be analysed and simulated. Then further with simulations the environment can be altered to train the car on other similar situations.

Aircraft pilots train in a similar way. This is the best possible circumstances for training drivers. There is such a long history of bus crashes and the numbers are already so low that there is a realistic chance of preventing all bus deaths across Europe.

But all of this is humans being augmented by computers. They are treated as the safety belt, there to catch exceptional circumstances. All the while computers can be learning from the bus drivers. Especially if the bus drivers have taken their advanced driving test then computers are learning the most consistent and safe method of driving.

## Business cost from crashes on the motorway

One of the potential but more extreme solutions is to ban amateur drivers from the motorway. It could be weakened to allow amateur drivers with an advanced license on the motorway.

One simple argument for this is the business cost of the delays that crashes cause. One crash delays thousands of people and lorries. The ring around Antwerp is a major example.

Reducing road deaths on the motorway to zero is within reach. Reducing the bad drivers on the motorway has a multiplying effect. It takes two bad drivers to crash. One who makes the mistake and the other that is too close.

There are some major issues with this solution:

• It will force bad drivers off the motorway and onto the normal roads. This will increase the death rate off the motorway
• Policing this will be a problem. A simple possibility is to have a letter in the car windscreen for all those with an advanced licence. Effectively a reverse learner sticker

## Lost time to driving

Professional drivers lose no time when driving a car, bus or lorry. There is no other work. They lose the time driving to their work. Effectively during this period they are amateurs too.

But all amateur drivers are losing time. Perhaps it is more pleasurable than being stuck on a train. But it’s wasted time.

The first area where level 4 (fully autonomous) vehicles will become a reality will be on motorways. It would be possible to allow self-driving whilst on a motorway but switch it off once the GPS detects that the car has left the motorway. This would cut down on motorway deaths, save businesses money from less delays and give more free time to commuters.

## The cost of the dead

Those who die in car crashes are a specially tragic kind of death. They almost always have nothing wrong with them. They are mentally and physically healthy. They are also often young and espcially cruel when it is young children, for example pedestrians.

The economic cost is put at \$5m per person based on the amount of output that an average person can have. But the wasted effort is bigger when the person is killed younger. All the training and education has been given but they never get a chance to repay that back into society.

But that does not take into account of the destroyed lives of the families of the victims. Parents who lose their children, siblings who lose their brothers and sisters, children who lose their parents. Further the economic cost of the victims families who struggle to work for years after the death.

Why do people not feel/see this pain? We stick horror photos of smokers on packets, but nothing of the crash victims on cars.

The biggest insult is that of drink drivers. The thought of having your child killed by a drunk driver. Death by human stupidity. Not someone evil just someone stupid.

No other amateurs can do such damage. Professionals practically never do this. There will be cases, but the cases are so few that it is at a level at which no more can be done.

One potential improvement is to increase the requirements of the driving tests. In the UK there is the advanced driving test, which tests candidates in many extreme situations as well as increased road safety and traffic awareness. The insurance premium for advanced drivers is lower.

A further possibility would be to require new driving tests every 10 years and requiring the level of advanced driver.

These tests should also be mandatory for professional drivers but the hope is though that it will be easier for them to pass and they will get the added benefit of lower insurance premiums when driving for themselves.

This will smooth the transition to automated cars as humans will behave at a level that is closer to professional drivers.

## Driving freedom

The major issue with restricting amateur drivers is the freedom and reliance we have on cars.

If we were to restrict who can go on motorways it would restrict poorer people unfairly. They cannot afford to buy expensive automated cars.

Is there research of social status with driving deaths?

But we are not completely restricting driving just on motorways for those without an advanced licence. So the freedom is still there just a bit slower.

Plus retaking your licence every 10 years.

But it is restricting a freedom that exists now. People are happy to accept the deaths for the freedom.

But commuters don’t need the freedom. Take it away from the rich with their business cars with cheap taxes. Commuters could take taxis and buses. Introduce toll roads, the French payage system is perfect. Hike the prices during commuter times but make exceptions for professional drivers.

## Difficulties

There was a bus lane in London that received a lot of complaints and it was eventually stopped because it was too much of a political issue. In Belgium, bus lanes still exist in the slow lane. But it could be a professional lane which means lorries as well. This means that the lane would be fully used.

It would be very unpopular though.

The ultimate is to prevent amateur drivers from using the motorway. But you can’t prevent foreign drivers. You could restrict them to lorry speeds unless they have a pass. The car pool lane, but now the professional or advanced drivers lane.

Bringing in an advanced test and also a 10 yearly driving test. Then you can force up the level of driving. But then the whole population must do a driving test. The system can’t cope now. There’s not enough driving instructors.

## Simulations

The automated test could be increased. Along with sight and danger tests.

Also a focus on time, keeping the 3 second rule, increasing it in rain and ice.

We have a limitation of driving instructors, but driving simulations can be drastically improved. There are very realistic driving simulation games with highly accurate physics. These games are played by children but with no emphasis on them being a useful tool.

This is how pilots are trained, they do thousands of hours in a simulator, repeatedly learning disaster scenarios.

All drivers could be put through multiple simulations of crash scenarios or taking on a skid pan as would happen with a regular advance driving test. They could drive around virtual driving cones until such time as they can master it. Mastery of the situation should be the key.

Currently it is very costly to take a driving theory test. They could be made harder but made a fixed price that allows as many retakes as required. This is a similar concept as put forward for learning with Khan Academy, mastery is the importance, getting 100% on the test whilst allowing as many retakes as required.

A further benefit is that the data collected by the driving simulations can be used to train the AIs. To see how a human handles a crash and also gain insight into the multiple attempts at the same crash and see which methods can be used to avoid a crash.

## Conclusion

The focus should be on improving and replacing amateur drivers whilst augmenting professional drivers. This is a highly unrealistic hope as the focus for self-driving car companies now is simply to cut the human cost of drivers. But the human cost of death should be regarded as a higher priority, with a requirement for public policy to intervene.