Posts

Showing posts from January, 2018

Angular2 - data bindings concepts

Important import : import { FormsModule } from '@angular/forms' And include this into your app module  imports :[ ... , FormsModule ] Two way data binding (banana box syntax) < input id = "name" type = "text" [( ngModel )]= "name" /> Or your can do it the longer way : < input id = "name" type = "text" [ ngModel ]= "name" ( ngModelChange )= "valueChange($event)" /> valueChange ( value ){ } Party on!

walk through word2vec python tensorflow basic

Image
Understanding embedding in tensorflow You will get a better understanding going through the content below, but first, we need to get some key concepts going. Step 1 we need convert text into words with an id assigned to it. For example we have " word_ids " defined which contain "we" "are" "the" "world" - shape 4, with 4 integer. Next, we need to map " word_ids " to vector using "tf.nn.embedding_lookup". Results are given in "embedded_words_ids" which contains a shape(4) and what these words means in a specific context given our vocabulary. word_embeddings = tf . get_variable (“ word_embeddings ”,     [ vocabulary_size , embedding_size ]) embedded_word_ids = tf . nn . embedding_lookup ( word_embeddings , word_ids ) Basically the same program used in word2vec basic tensorflow example but I used a smaller dataset. There are just example with 100 different word (which will be discussed later

word2vec tensorflow example : word embeddings function reference

Image
Walking through the word to vector basic example :- Quoting from  s0urcer The idea of skip-gramm is comparing words by their contexts. So we consider words equal if they appear in equal contexts. The first layer of NN represents words vector encodings (basically what is called embeddings). The second layer represents context. Every time we take just one row (Ri) of first layer (because input vector always looks like 0, ..., 0, 1, 0, ..., 0) and multiply it by all columns of second layer (Cj , j = 1..num of words) and that product will be the output of NN. We train neural network to have maximum output components Ri * Cj if word i and j appear nearby (in the same context) often. During each cycle of training we tune only one Ri (again because of the way input vectors are chosen) and all Cj, j = 1..w. When training ends we toss the matrix of the second layer because it represents context. We use only matrix of the first layer which represents vector encoding of the words. read_d

Install-Package "System.ValueTuple"

This is the best command i executed this week and it gives me the ability to use de-structuring, multiple return and local function. Awesome stuff.

sourcetree can't revert merge

Sourcetree is pretty bad when it comes to reverting a merge. So you might have to use the terminal and type out the following field. git revert -m 1 HEAD

tf working with tf.decode_csv

In the documentation it says, convert csv file into tensor. Not really sure what it means by tensor. Anyways, here is some example working with the codes :-

tensorflow : working with tf.data.TextLineDataset

Here is a simple example of working with tf.data.TextLineDataset

Angular5 post seems to be posting null values to webapi core controller

Getting Angular5/6 HttpClient to post JSON object to a WebAPI (.Net Core) seems to be passing null value to your simple/complex model for example, EmployeeModel.  There are alot of component you need to get right. Key changes include:- a) CORS Setup - In your WebApi's Startup.cs you need to configure CORS correctly.  Please have a look at code below, i have configure my CORS to accept any methods and any header. app.UseCors(option => option.WithOrigins( " * " ).AllowAnyMethod().AllowAnyHeader()); The complete code snippet is shown here. b) Header - You need to configure 'Content-Type' wth application/json in your HTTP POST calls and not forgetting the subscribe() method call - to execute method now. :) const headers = new HttpHeaders (). set ( 'Content-Type' , 'application/json; charset=utf-8' ); this . http . post ( APPLICATION_HOST + '/user/save' , "{name:'jeremy', username : 'wooo&#

angular reactiveform, templateform and dynamicform

Yeap if you have the feeling these are all different methods used in constructing forms, then you're right. ReactiveForm - uses reactive style to work with form. It would uses reactive way to monitor, track interaction with the forms. To work with this you need to use FormGroup to create a series of control for your form or just FormGroup an individual element to tied to your HTML control. Please take a look at this to get an idea of how reactive form works. TemplateForm - uses the model and HTML approach whereby HTML tags are binded to a model DynamicForm - an approach that lets you create forms dynamically and faster by using ReactiveForm and cleverly using OO strategy to make sure questions are rendered dynamically.

Tensorflow quick example for using DNNRegressor for house prediction analysis

A quick and dirty code to run orchid classifier using tensorflow deep learning classifier

Parsing json giving unexpected token o error

Was getting this weird issue. If you do get this, the solution is don't parse your JSON, as it is already in JSON form

using Mssql server on docker

First of all, please ensure you install docker toolbox. Once you have done that, ensure you run the following command. If you  setup your command prompt to use docker, if not please follow the instruction here . Step 1 SET ACCEPT_EULA=Y SET SA_PASSWORD=P@ssword01 SET MSSQL_PID=Developer Run docker docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=P@ssword01" -p 1433:1433 -d microsoft/mssql-server-linux:latest Please note: ensure to use double quote for windows, other wise it would not work. if you face any issues, please run docker log to get the latest runtime messages

.netcore project appeared not to be running with thread exited

Image
If you encounter this issue, the fix is pretty straight forward. Just configure your project NOT to use IIS Express. Instead configure it to use whatever program name and output type to "Console App". That's it.

tensorflow - working with rnn basic methods

Creating RNN Cell #create a basic rnn cell import tensorflow as tf # create a BasicRNNCell rnn_cell = tf . nn . rnn_cell . BasicRNNCell ( hidden_size ) # create a LSTMCell rnn_cell = tf . nn . rnn_cell .LSTMCell ( hidden_size ) # create a LSTMCell rnn_cell = tf . nn . rnn_cell .GRUCell ( hidden_size ) Reshape reshape - reorganizes your tensor for example [1,2,3,4,5,6,7,8,9] into a specific shape. For example,  if your execute  a = tf.reshape(t, [3, 3]), the array above gets converted into :- array([[1, 2, 3],        [4, 5, 6],        [7, 8, 9]]) Softmax  The purpose of softmax is to flatten/normalizing input into a sum of 1. a = tf.constant(np.array([[.1, .3, .5, .9]])) print(sess.run(tf.nn.softmax(a))) Outputs [[ 0.16838508  0.205666    0.25120102  0.37474789]] Lets walk through the following simple rnn code and you figure out what is going on here.