2016年4月29日 星期五

machine learning note.

mean squared errors

Minimize MSE

loss = tf.reduce_mean(tf.square(y - y_data))

GradientDescentOptimizer

https://en.wikipedia.org/wiki/Gradient_descent

optimizer = tf.train.GradientDescentOptimizer(0.5)

train = optimizer.minimize(loss)

Logarithmic Loss

https://www.kaggle.com/wiki/LogarithmicLoss
import scipy as sp
def logloss(act, pred):
    epsilon = 1e-15
    pred = sp.maximum(epsilon, pred)
    pred = sp.minimum(1-epsilon, pred)
    ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
    ll = ll * -1.0/len(act)
    return ll

matrix product

import tensorflow as tf

matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])

product = tf.matmul(matrix1, matrix2)

#auto close session
with tf.Session() as sess:
  result = sess.run([product])
  print(result)
  # ==> [[ 12.]]

Placeholders

a value that we'll input when we ask TensorFlow to run a computation. creating nodes for the input images and target output classes.
x = tf.placeholder(tf.float32, shape=[None, 784])
y_ = tf.placeholder(tf.float32, shape=[None, 10])

Variables

Variable. A Variable is a value that lives in TensorFlow's computation graph. It can be used and even modified by the computation.
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))

regression model.

y = tf.nn.softmax(tf.matmul(x,W) + b)
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))

cross entropy

Why You Should Use Cross-Entropy Error Instead Of Classification Error Or Mean Squared Error For Neural Network Classifier Training
-tf.reduce_sum(y_ * tf.log(y)

neural networks

Rectifier ReLU

https://en.wikipedia.org/wiki/Rectifier_(neural_networks)

conv 2d

http://stackoverflow.com/questions/34619177/what-does-tf-nn-conv2d-do-in-tensorflow

2016年4月23日 星期六

python scientific computing (numpy scipy matplotlib)

numpy scipy matplotlib



Gradle Note

Gradle Java
Java plugin - tasks
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: 'findbugs'

group = 'com.my.Project .rules'
version = '0.1.0'

description = """AWS Project Rules  """
...
Project tree
project-rules/
    project-rules-core/
    project-rules-ws/
... Build see gradle java for all tasks https://docs.gradle.org/current/userguide/java_plugin.html build all
project-rules$> gradle build -Penv=dev (env=dev/stg/prd)
build only project-rules-core
project-rules$> gradle :project-rules-core:build
build project-rules-ws
project-rules$> gradle :project-rules-ws:build -Penv=dev
Run Unit Test
project-rules$> gradle test
  • test report: project-rules-ws\build\reports\tests 
  • findbug report: project-rules-ws\build\reports\findbugs 
Generate Code Coverage Report
project-rules$> gradle test jacocoTestReport

output: project-rules\project-rules-ws\build\reports\jacoco\test\html Run local Embedded Web Container - Jetty
project-rules$> gradle :project-rules-ws:jettyRun -Penv=stg
open url: http://localhost:8080/project-rules-ws/

2015年12月9日 星期三

2015年12月3日 星期四

Next Generation Eclipse ?

Che Eclipse : http://www.eclipse.org/che/



it's web based (browser) good theme , but no shortcut and assistant for me to ready use...

How to use maven launch embedded tomcat or jetty with plugin

Tomcat maven plugin

setup pom.xml

    org.apache.tomcat.maven
    tomcat7-maven-plugin
    2.2

$> mvn tomcat7:start

jetty maven plugin

  • http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html
  • resources in ${project.basedir}/src/main/webapp
  • classes in ${project.build.outputDirectory}
  • web.xml in ${project.basedir}/src/main/webapp/WEB-INF/

    
    org.eclipse.jetty
    jetty-maven-plugin
    9.3.1-SNAPSHOT
    
        10
        
            /test
        
    

$>mvn jetty:run

2015-12-3 digest


Maven

AWS

BigData

Github