Saturday, April 29, 2017

Gradient Descent's role in Linear Regression

Over the past few weeks we opened our discussion of machine learning and neural networks with an introduction to linear classification that discussed the concept of parameterized learning, and how this type of learning enables us to define a scoring function that maps our input data to output class labels.
This scoring function is defined in terms of parameters; specifically, our weight matrix W and our bias vector b. Our scoring function accepts these parameters as inputs and returns a predicted class label for each input data point x_{i}.
From there, we discussed two common loss functions: Multi-class SVM loss and cross-entropy loss (commonly referred to in the same breath as “Softmax classifiers”). Loss functions, at the most basic level, are used to quantify how “good” or “bad” a given predictor (i.e., a set of parameters) are at classifying the input data points in our dataset.
Given these building blocks, we can now move on to arguably the most important aspect of machine learning, neural networks, and deep learning — optimization.
Throughout this discussion we’ve learned that high classification accuracy is dependent on finding a set of weights W such that our data points are correctly classified. Given W, can compute our output class labels via our scoring function. And finally, we can determine how good/poor our classifications are given some W via our loss function.
But how do we go about finding and obtaining a weight matrix W that obtains high classification accuracy?
Do we randomly initialize W, evaluate, and repeat over and over again, hoping that at some point we land on a W that obtains reasonable classification accuracy?
Well we could — and it some cases that might work just fine.
But in most situations, we instead need to define an optimization algorithm that allows us to iteratively improve our weight matrix W.
In today’s blog post, we’ll be looking at arguably the most common algorithm used to find optimal values of W — gradient descent.

Monday, April 24, 2017

Google Drive API Error: The user has not granted the app XXXXX read access to the file YYYYYY

If you get an error like this one:

"error": {
"errors": [
"domain": "global",
"reason": "appNotAuthorizedToFile",
"message": "The user has not granted the app 183181265754 read access to the file 0B7unS-zlQOGYcjhnOUJkNDY5Z0E.",
"locationType": "header",
"location": "Authorization"
"code": 403,
"message": "The user has not granted the app 183181265754 read access to the file 0B7unS-zlQOGYcjhnOUJkNDY5Z0E."

Make sure you have DRIVE , METADATA and DRIVE_FILE scope permissions set in your client code. Like this (PHP):

define('SCOPES', implode(' ', array(

For example, if DRIVE is missing, it's going to return that error. Also, make sure that your service account's email is added to share list of the file/folder you're trying to access.

Sunday, April 23, 2017

WPEngine - sessions disabled for non-logged in users

At WPEngine, their caching disables sessions by default. Session ID is being changed all the time by default, for non-logged  in users.

They need to be contacted to enable normal session usage:

They can enable sessions on some pages, and disable them on the rest, which is kinda cool.

Tuesday, April 18, 2017

How to fix external USB HDD for which Windows report: "You need to format the disk in drive X"

If Windows report "You need to format the disk in drive ..." for your NTFS external HDD, then you can try this.

Use Ubuntu or any other Linux, and try to open your disk with it. If Ubuntu gives you an error stating something like partition is smaller than NTFS, you can try to run this tool:

sudo ntfsfix /dev/yourdevice

For example:

sudo ntfsfix /dev/sdb1

If it fails, it should at least  give you some more details on what's wrong with the HDD.

It saved my disk ! :)

Monday, April 17, 2017

For non-SPA pages, make page browsing work without screen flicker

If you would like to avoid screen flicker while the user surfs the site, here are a few ideas:

The main idea to try is this css:

body {
  background: url("Images/sky01.jpg") repeat scroll 0 0 #121210;
  font-family: Verdana,Geneva,sans-serif;
  font-size: 12px;
  margin: 0;
  padding: 0;

Tuesday, April 11, 2017

Some tips for Laravel installation on Windows

1.PHP interpreter path and version

If you need to update your php version , just dowload PHP executable and save it to a folder. Add that folder to PATH and make sure it's the first php.exe in the PATH's folder list.
Rename php.ini.development to php.ini and uncomment the extension you need. You will need mbstring and openssl for sure (otherwise composer update will fail).

More tips will be added soon:)

2. Non-Windows related: Accessing external classes added via composer (in Laravel controllers):


$objReader = \PHPExcel_IOFactory::createReader($type);

Where PHPExcel represents PHPExcel library.

Monday, April 3, 2017

How to make HTML body tag take 100% of height

It's always good to remember how to make body tag to occupy 100% of document height.

Here's a little reminder from Stack Overflow:

up vote202down voteaccepted
In order for a percentage value to work for height, the parent's height must be determined. The only exception is the root element <html>, which can be a percentage height. .
So, you've given all of your elements height, except for the <html>, so what you should do is add this:
html {
    height: 100%;
And your code should work fine.
* { padding: 0; margin: 0; }
html, body, #fullheight {
    min-height: 100% !important;
    height: 100%;
#fullheight {
    width: 250px;
    background: blue;
<div id=fullheight>
  Lorem Ipsum        

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...