knowledge_base:programming:machine_learning

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
knowledge_base:programming:machine_learning [2022/12/02 14:45] – removed - external edit (Unknown date) 127.0.0.1knowledge_base:programming:machine_learning [2023/02/18 12:12] (current) – [Useful Resources] Normal User
Line 1: Line 1:
 +====== Machine Learning ======
 +
 +
 +===== Useful Resources =====
 +
 +http://www-bcf.usc.edu/~gareth/ISL/\\
 +https://www.r-project.org/about.html\\
 +https://www.rstudio.com/products/rstudio/\\
 +https://www.kaggle.com/c/digit-recognizer\\
 +[[https://www.guru99.com/tensorflow-tutorial.html|TensorFlow and general SW learning website]]
 +
 +References
 +
 +[1] C.J. Wu et al., Machine Learning at Facebook: Understanding Inference at the Edge [From Facebook]\\
 +[2] N.P. Jouppi et. al., In Datacenter Performance Analysis of a Tensor Processing Unit [From Google]\\
 +[3] Vivien Sze et. al., Efficient Processing of Deep Neural Networks: A tutorial and survey [From MIT]\\
 +[4] Amr Suleiman et. al., Navion: A 2mW Fully Integrated Real-Time Visual-Inertial Odometry Accelerator for Autonomous Navigation of Nano Drones [From MIT]
 +====== Handwriting Learning Code Example ======
 +
 +===== Example 1 =====
 +
 +<code>
 +library(h2o)
 +h2o.init(nthreads = 6)
 +h2o.removeAll()
 +traindat=read.csv("train.csv")
 +traindat[,1] = as.factor(traindat[,1])
 +traindat[,2:785] = ifelse(traindat[,2:785]>20, 1, 0)
 +par(mfrow = c(10,10), mar = c(0,0,0,0))
 +for (i in 1:100) {
 +  y = as.matrix(traindat[i,2:785])
 +  dim(y) = c(28,28)
 +  image(y[,28:1], col = gray(1:0), axes = FALSE)
 +  text(0.2, 0, traindat[i,1], cex = 3, col = 2, pos = c(3,4))
 +}
 +train.h2o = as.h2o(traindat)
 +nnmodel.h2o = h2o.deeplearning(
 +  x = 2:785,
 +  y = 1,
 +  training_frame = train.h2o,
 +  activation = "RectifierWithDropout",
 +  input_dropout_ratio = 0.2,
 +  balance_classes = TRUE,
 +  hidden = c(1024,1024,1024),
 +  l1 = 1e-5,
 +  classification_stop = 0.001,
 +  epochs = 100
 +)
 +testdat = read.csv("test.csv")
 +testdat = ifelse(testdat>20, 1, 0)
 +test.h2o = as.h2o(testdat)
 +pred.h2o = h2o.predict(nnmodel.h2o, newdata = test.h2o)
 +pred = as.data.frame(pred.h2o)
 +par(mfrow = c(10,10), mar = c(0,0,0,0))
 +for (i in 1:100) {
 +  y = as.matrix(testdat[i,])
 +  dim(y) = c(28,28)
 +  image(y[,28:1],col = gray(255:0/255), axes = FALSE)
 +  text(0.2, 0, pred[i,1], cex = 3, col = 2, pos = c(3,4))
 +}
 +</code>
 +
 +===== Example 2 =====
 +<code>
 +library(h2o)
 +h2o.init(nthreads = 6)
 +h2o.removeAll()
 +train.h2o = h2o.importFile("train.csv")
 +train.h2o[,1] = as.factor(train.h2o[,1])
 +nnmodel.h2o = h2o.deeplearning(
 +  x = 2:785,
 +  y = 1,
 +  training_frame = train.h2o,
 +  activation = "RectifierWithDropout",
 +  input_dropout_ratio = 0.2,
 +  balance_classes = TRUE,
 +  hidden = c(1024,1024,1024),
 +  l1 = 1e-5,
 +  classification_stop = 0.001,
 +  epochs = 100
 +)
 +test.h2o = h2o.importFile("test.csv")
 +pred.h2o = h2o.predict(nnmodel.h2o, newdata = test.h2o)
 +testdat = as.data.frame(test.h2o)
 +pred = as.data.frame(pred.h2o)
 +par(mfrow = c(10,10), mar = c(0,0,0,0))
 +for (i in 1:100) {
 +  y = as.matrix(testdat[i,])
 +  dim(y) = c(28,28)
 +  image(y[,28:1],col = gray(255:0/255), axes = FALSE)
 +  text(0.2, 0, pred[i,1], cex = 3, col = 2, pos = c(3,4))
 +}
 +</code>
 +