Wednesday, August 17, 2016

Are We Living in a Computer Simulation

Elon Musk thinks that is it almost certain that we are living in a computer simulation. He Says that humans are basically an advanced version of The Sims. Indeed this idea sounds pretty absurd. But people used to think all planets including sun orbits around the Earth and almost 2000 years ago Galileo proved that is it not. There for the reality could far different from what we are materializing.




If we are living in a simulation, there is a higher level being, but it’s some version of us


Musk is echoing a paper on this theory by Oxford professor Nick Bostrom. His argument goes like this. 40 years ago we had Pong, like two rectangles and a dot. 30 years later we got The Sims, and now 40 years later we have photorealistic 3D simulations with millions of people playing simultaneously and it is getting better every year.

So let’s go about 10000 years in to the future and it’s possible that when we get there, the entire civilization is gone because there is a celling to our advancement. It could be because of global warming or self replicating robots. Quoting Elon, “… if civilization stops advancing, that may be due to some calamitous event that erases civilization”. But another possibility is that if we keep advancing and assuming everything in the physical world can be simulated, eventually we will simulate ourselves.

Getting enough computer power to run billions of ancestor simulations could be a problem. But Bonstrom thinks we’d send tiny self replicating robots to other planets which would turn the planet into a huge computer and some of the simulations would start making their own simulation. In this scenario there are billions of universes that are indistinguishable from our own. That means chances are we are in one of the simulated universe. And given the other possibility, which is human civilization has an inevitable ceiling. Obviously it’s better that we are in a simulation.

Somehow there is another possibility. Maybe future humans don’t want to run ancestor simulations. Maybe because they think it’s unethical to run ancestor simulations. Because there is a tremendous amount of suffering in the world, and that suffering would still feel real to simulated humans. Or maybe they have other priorities.



However, there are three possibilities, (1) humans go extinct before we are able to run a simulation this big, (2) humans don’t run simulations because it is wrong or boring, (3) we are living in a simulation. Musk think there is only a tiny chance we are in scenario 1 or 2 and the Bostorm thinks it is more like a 20% chance that we are in a simulation but if you are not into futuristic predication,  Bostrom think the argument also provides other rewards. He says, “… it suggests naturalistic analogies to certain traditional religious conceptions”. In other words, if we are living in a simulation, there is a higher level being, but it’s some version of us.

References:

Are You Living In a Computer Simulation? Nick Bostrom. Philosophical Quarterly, 2003, Vol. 53, No. 211, pp. 243-255.

Full interview of Elon Musk at Code Conference 2016

Saturday, July 30, 2016

International Conference on IoT for Smart Living

I’ve just returned from International Conference on IoT for Smart Living, which was held in Colombo, Sri Lanka. It was my first time attending to an IoT conference, and I was very pleasantly impressed on many levels including conference organization and breadth of the talks delivered.



In day to day life as a software engineering practitioners we tend to think in terms of solving the problem and getting results in the best possible way. In that process, we choose the best technologies we could utilize, and the most promising software stack that could help us to simplify the lives of both people and us (developers). The hardest part of this process is not implementing the solution as a product, but give a solution that simplify the problem. This is something really important thing I learned from most of the presentations we had.

The keynote speech of the conference was delivered by Mr. Wasantha Deshapriya, who is the secretary of the Ministry of Telecommunication and Digital Infrastructure. His speech was on “IoT Country Readiness in Digital Sri Lanka”. Throughout his speech, Wasantha highlighted how Sri Lankan is introducing eGovernance to improve the efficiency and impact of public sector, and the need of national level policy (or rather a roadmap) to leverage IoT to accelerate the current work being done.

Morning session had three more speeches other than the keynote speech. Dr. Rishi Bhatnagar, who is the president of Aeris Communication India, Mr. Shivananda Koteshwar (Shivu) who is the Director of Technology at Media Tech India were delivering speeches of the evolution of IoT , Global prospectives of IoT and Smart Cities. Both of them were able to share some insights of IoT in India, where most of the focus is on utilizing IoT to take good care of the senior population, mitigating the problems of urbanization, and climate change. Also, Dr. Rishi highlighted the dimensions of cost, security, right skillset, mindset and cultures readiness, regulations and some technical aspects such as interoperability of devices and long lasting batteries.

Mr. Ajit Ashok Shenvi, who is the Director of Big Data & Analytics at Philips Innovation Campus, Bangalore was also delivered a speech in the morning. He was more focused on IoT in Healthcare. In his speech one thing that I noticed is the new business models that emerging with IoT such as “charge per service, not for the product” (Philips MRI scanners are available as a service in India as I heard).

We had four speakers delivering speeches in the evening. Mr. Pradeep De Almeida, Group CTO of Dialog Axiata delivered an insightful talk on IoT Infrastructure Development in Developing Country Perspective. The speech contained details about protocols that could leverage in developing country’s context of IoT. But the most important part is a use case that he presented complex problem and solved it without any technological infrastructure (I have attached a video below on that). His point was, “If you see a problem, simplify it and solve with minimal complexity. Later move for a more sophisticate solution peacefully”.



Mr. Wellington Perera from Microsoft and Mr. M. I. Deen fro Sri Lanka Telecom also presented in the evening session. The second most important speech of the evening session was delivered by Dr. Chathura De Silva, who is the Head of the Department of Computer Science and Engineering at University of Moratuwa. Where he demonstrated how he has done home automation to wire up things at his home. This presentation was one of exciting one we had.

In sum, IoT haven’t been in a level that would motivate me to attend to a conference, but this participation was refreshing and worth the time I spent there.

Tuesday, July 19, 2016

Understanding Softmax Regression


This is going to be short... Very short!


Reason being this post is too short is it's Pokemon Go time :)

Logistic regression is where we simply classify a set of values into two known classes. For example predicting whether a grid of pixels intensities represent a “0” or “1” digit. Now let’s consider a situation where we have to predict which digit a grid of pixel intensities are representing. This is exactly a generalization of Logistic regression, where we have to perform a multi-class classification. Hence we could also refer this as “Multinomial Logistic Regression”, which is also referred as the “Softmax Regression”.

Given an input x, our hypothesis will estimate the probability of the class label of the K different possible values and output a K-dimensional vector resulting K estimated probabilities.

Sunday, July 3, 2016

Data Flow Graphs

In data flow graphs, computation is programmed as a directed graph. This graph enables the data flow across operations, where each node in the graph represents an operation or a computation. A node may send, receive or can send a response to a message that they received.



In the above data flow graph, the left most node generates the integer values from 1 to 10 and passes them to two successor nodes. One of the successors squares each value it receives and passes the result downstream. The second successor cubes each value it received and passed the result downstream. The right most node received values from both of the middle nodes. As it receives each value, it adds it to a running sum of values. When the application is run to completion, the value of sum will be equal to the sum of the sequence of squares and cubes from 1 to 10.

Given below is a pseudocode that represents above computations. Each function in the pseudocode is equivalent to a node in the graph.

Saturday, June 25, 2016

Data Types, Sessions and Other Basic Usages of TensorFlow


TensorFlow is a computational framework that allows users to represent computation as a graph. Nodes in this computational graph represents an operation to be performed, which is called “op” in TensorFlow context. An op can take zero or more Tensors and produce zero or more Tensors as it’s output. Tensor can be referred to as a multi-dimensional array. 

In this post I’ll be focusing on Computational graphs, Sessions, Tensors, and Variables.

Typical TensorFlow graph has three main phases, which are Construction phase, Graph Assemble phase and Execution phase. By default TensorFlow provides a computational graph where users can assign ops that needs to be executed without assembling a new graph. 



Operations and Tensors

A Tensor represents the data flow through ops, in other words a value consumed or produced by an op. Tensors does not hold the value of that operation, instead it handles as a symbolic handle to an output of an op. In this perspective, Tensor plays two roles; it can be passed as an input to an op which allows to build the graph and it’s data flow, Secondly it allows to perform computations on values being passed. In below, matrix_1, matrix_2 and product are Tensors.

matrix_1 = tf.constant([[3., 3.]])
matrix_2 = tf.constant([[2.], [2.]])
product = tf.matmul(matrix_1, matrix_2)

Like mentioned previously an operation or op is a node in TensorFlow graph that can both consume or produce zero or more Tensors. Ops performs computations on Tensors. For example,

product = tf.matmul(matrix_1, matrix_2)

Creates an operation of type “matmul” and takes matrix_1 and matrix_2 tensors as inputs to produce product tensor as output.

Graphs

A graph in TensorFlow can be referred as a collection of Ops that linked by Tensors and can be start with ops that doesn’t take any input and pass their output to other ops that performs computations. In below example we have added three ops including two constants and one op to TensorFlow default graph. To launch and get the results we must execute the graph in a TensorFlow session (more on Sessions later).


matrix_1 = tf.constant([[3., 3.]])
matrix_2 = tf.constant([[2.], [2.]])
product = tf.matmul(matrix_1, matrix_2)

sess = tf.Session()

result = sess.run(product)

Sessions

A session contains all operations and tensors of a computational model. It does execute ops and evaluates tensors. The default session can be launched without giving any graph arguments when creating the session. If it’s required to run different graphs in different sessions, the we have to provide which graph should be executed in each session we are creating.

TensorFlow session represents a connection to it’s underline native libraries. So it holds all resources allocated until we close the sessions. Or else we could user session as a context manages.

matrix_1 = tf.constant([[3., 3.]])
matrix_2 = tf.constant([[2.], [2.]])
product = tf.matmul(matrix_1, matrix_2)

sess = tf.Session()

result = sess.run(product)

print(result)
sess.close()

To execute above example with session as a context manager,

matrix_1 = tf.constant([[3., 3.]])
matrix_2 = tf.constant([[2.], [2.]])
product = tf.matmul(matrix_1, matrix_2)

with tf.Session() as sess:
result = sess.run(product)

print(result)

Variables

Variables keeps state across TensorFlow graph executioin and can be considered as in-memory buffers of Tensors. Variables should be explicitly initialized and can be stored in the hard disk to use them later on.

To create a variable we must pass a Tensor as it’s input parameter to the constructor.

x = tf.Variable([1.0, 2.0])
a = tf.constant([3.0, 3.0])

# create a variable that will be initialize to scalar value 0.
state = tf.Variable(0, name="counter")

# variables must be initialized by running an 'init' op after having
# launch the graph. first add the init op to the graph.
init_op = tf.initialize_all_variables()

In another post, we will be dive deep into data flow graphs for better understanding of computation executions.

For source code: https://github.com/isurusiri/tensorflowbasics

Setting Up TensorFlow Environment for CPU Based Usages


Deep learning has done wonders work in both Natural Language Processing and Image Processing in last few years. Even though some of these algorithms has been existed for decades, recently performance have been improved and ultimately proved its capabilities by the improvements in hardware infrastructure and accumulated huge data volumes. 

This improvements has lead development and research communities to introduce frameworks consist of deep learning algorithms. Caffe, CNTK, DeepLearning4J, Torch, Theano and TensorFlow are some of the very famous deep learning libraries at the moment.

First things first, I am not a deep learning expert. Luckily I had the opportunity work very closely with some deep learning focused researches soon after I graduated. 

I have been working with Convolutional Neural Networks and Autoencoders in last few months and I was evaluating few of above mentioned libraries, but TensorFlow seemed to like the Chuck Norris of deep learning libraries. In this post I will give the instructions to setup TensorFlow for CPU base usages and run the “Hello world!”.



In here I assumes the environment is Ubuntu and have installed Python 2.7 or 3.0+.

First install the PIP package manager.

$ sudo apt-get install python-pip python-dev

Set and environment variable for the Tensorflow binary release (here I have added 64bit Python 2.7 version).

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

Just install the TensorFlow now.

$ sudo pip install --upgrade $TF_BINARY_URL

To test the TensorFlow, open terminal and execute,

$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>>

That’s it, everything should work perfectly. Note that you might have to remove any installations if you have installed TensorFlow before.

In next post I’ll introduce basic usages of TensorFlow.

For source code: https://github.com/isurusiri/tensorflowbasics


Sunday, May 1, 2016

The True OLAP

OLAP or simply OnlineAnalytical Processing is the process that allows users to conduct multidimensional interaction analysis operations on real-time business data. This includes performing operations such as drilling, aggregating, pivoting, and slicing multidimensional data.

It is necessary to create topic specific data cubes in advance to support above operations, thereby users can inspect data in tables or graphs and conduct real time pivoting and drilling. Having said that, let’s consider whether OLAP is enough for catering analysis and forecasting in real world.

Figure 1: Information Systems can be divided into transnational (OLTP) and analytical (OLAP). In general OLTP provide source data to data warehouse, whereas OLAP helps to analyze it.


A mature company may have somewhat large data accumulated about its operations. These data can be used to make certain guesses about the business they are engage in. For example, a vehicle importer may guess what kind of people are tending to buy what kind of vehicles. These guesses are just the basis for forecast. Then the company could utilize accumulated data to evaluate above guesses. When a guess evaluated to be true they can be used in forecast and when it is false they will be re-guessed.

Above process could be referred as evaluation process, whose purpose is to justify conclusions with evidence find in historical data. In business analysis process, a query like the first n customers who has purchased a vehicle from vehicle types contributed for half of the sales volume of the company in the year the x is ubiquitous and required some form of a computation or querying, with intermediate steps.

The requirement of building the data cube in advance, and a limited set of actions available to perform against data cube are limiting the analysis process in a situation like above. The data model needs to have capabilities of reconstructing the cube or temporarily build cubes to cater diverse analysis demands. Furthermore, most of the OLAP products are more famous for their rich user interface; only a few has powerful online analytical capabilities.

Figure 2: In OLAP database there is aggregated, historical data, stored in multi-dimensional schemas (usually star schema).

So what kind of an online analytical tool could fulfill the evaluation process? Theoretically, steps for evaluation can be considered as computation regarding data. This computation can be defined by user and can decide next computation actions to be taken based of the intermediate results without having a defined model beforehand. Additionally this computation should support performing actions on huge amount of data instead of simple numeric computations. At this point of view, SQL is somewhat fulfilling this requirement, but considering its own computational capability, still it has its own limits on solving problems similar to above mentioned problem. This leaves us in a position to think about the limitations of SQL and builds a way through it to make a new generation of computational system for evaluation process, namely, the real OLAP.

I’m still completely a novice in Business Intelligence. J