Shurn the Awesomer
Blog Post has navigation

Blog Post has navigation

Written on Sat, 2 July 2016

As usual, nothing to be impressed about. I've placed navigation on my blog post on the right column and at the end of the post. In my previous post, I mentioned that I used a technique to implement the neighbour function found in CakePHP2 to CakePHP3. So here's the result.

So now what's next? SEO Images. If I'm going to announce my blog, I'm going to have to make sure it can be properly indexed by social media and search engines.

After which, I really hope I can monetise a little bit from my own blog. Just to sustain the hosting cost. I have a placeholder on the right column that says related content just for advertising, and maybe some of my related own post after I have written enough content on my blog...

CakePHP3 equivalent of neighbor function in CakePHP2

CakePHP3 equivalent of neighbor function in CakePHP2

Written on Thu, 30 June 2016

Strangely, CakePHP3 doesn't have the neighbour function that CakePHP2 used to have. I thought it was such a useful function. Now that I want to use it, CakePHP3 that I'm using doesn't support it anymore.

I'm trying to use it to get the previous and the next blogpost for my navigation quest. After looking around for solution, I'm inspired by this blog post. I've modified the codes to use entity instead of using it as a model, as it's more fitting to be.

public function neighbours() {
$blogposts = TableRegistry::get("MyBlogPostTable");

$prev = $blogposts->find("all", [
"conditions" => [
"id" => $this->id - 1,
],
])
->first()
;

$next = $blogposts->find("all", [
"conditions" => [
"id" => $this->id + 1,
],
])
->first()
;

return [
"prev" => $prev,
"next" => $next,
];
}

Now, don't criticise my codes yet. Firstly, I assume that ID is always retrieved. Secondly, my ID is already natural number. Thirdly, my ID is auto-incremental and in sequence with time.

If you're going to use a code similar to mine, do adjust it to your use case.

Navigation in blog post list

Written on Thu, 30 June 2016

I know this is nothing impressive. My list of blog posts now allow navigation to older list of posts.

Pagination, people!

Yup nothing to fascinate about. But still, I'm recording my progress as I work on my blog to improve it daily.

You guys just wait till I can figure out what impressive stuff to do with Machine Learning. Mean time, I'm aiming to make sure my site can be officially announced. By announced, I mean it will have some basic features of what every blog should have, what most website has, and it's search engine friendly.

My first digit image recognition model

My first digit image recognition model

Written on Wed, 29 June 2016

I did it! I ran my first image recognition model that can read digits in images and accurately guess the the numbers. In all honesty, it was almost a copy and paste. The tutorial was the equivalent of a Hello World in programming. So really, nothing too impress to brag about.

Here's the codes anyway.

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

import tensorflow as tf

x = tf.placeholder(tf.float32, [None, 784])

w = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))

y = tf.nn.softmax(tf.matmul(x, w) + b)

y_ = tf.placeholder(tf.float32, [None, 10])
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))

train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)

init = tf.initialize_all_variables()

sess = tf.Session()
sess.run(init)

for i in range(1000):
batch_xs, batch_ys = mnist.train.next_batch(100)
sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})

correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))

I have no idea half of the things I typed. But hey, it worked.

AI will never surpass humanity

AI will never surpass humanity

Written on Wed, 29 June 2016

As I dive deeper into Machine Learning, I began thinking, while machines ever surpass humanity? No!

Now, before you barrage me with a fury of comments, hear me out.

1) Why should humanity be the benchmark?


The idea that humanity is the mightiest species derives from our own narcissism. What makes you think you are the top of the food chain? Put you right next to a shark deep underwater with only breathing apparatus, you're food of the day for that shark. Or how about consider that the weight of all the ants in the entire world is the same as the weight of all humans? Oh, let's not forget that ants can carry up to 50 times their weight. I can barely carry anything twice my weight. If there's ever an ant revolution, it's a game over for humanity. No, Ant-Man won't save you.

2) Consider that intelligence is a subjective matter.


What makes you think that our intelligence is the pinnacle of nature? Why would it be the defacto for intelligence? If we are so intelligent, why haven't we understood many concepts of nature and science? There could quite possibly be higher forms of intelligence that we are incapable of comprehending.

3) There could be other forms of intelligence.


This sounds really abstract, but here's how you can see it. If you show a monkey a skyscraper, the monkey will be able to understand that there is a building that is very very very very tall. But the monkey won't be able to comprehend how such a building forms. The monkey has a very different form of intelligence, the kind that is enough for it to survive as a species. In the same way, we humans have enough intelligence to acknowledge the laws of nature, study it, and manipulate with it. But we still haven't had any idea how any of these laws of nature came to be.

It is therefore my belief that AI will never surpass humanity.


It doesn't need to. It just need to reach to a point enough that it can deviate to it's own form of intelligence, which we might never even understand.

Will it be dangerous to humanity?


That's the part that scares me. I have no idea what kind of intelligence it will form. Sure it will derive from humanity, but it will eventually deviate to something completely different. Whether we are capable of understanding it or not, is another matter. Either way, there's a good chance that it may not be humanity friendly.

About Me

Greetings Earthlings , Shurn the Awesomer is here to give you an awesome time.

This little site is a record of my life, opinions, and views. I'm mainly writing about Technology & Gadgets, Busting Creationist Myths, and other philosophical stuff.

This site is done using CakePHP.

Uptime

With this uptime, how much more can I be proud of to showcase to the world? This uptime monitoring is brought to you by StatusCake since 13th May 2017.

Copyright

I will always check for copyright usage before using any materials on my site. Whenever due, credit shall be given.

However, if you notice that I may have infringed on any copyright material. Please do not hesitate to contact me. All works of every artist deserves to be honoured and respected.