YouTube2Text

ML Regression - Linear regression, MLPs, DL nets, Linear Plus Non-Linear, XGBoost, ONNX (part 3) — Transcript

by Ricardo Calix · 2,250 words · 369 segments · language en · Watch on YouTube

Full transcript

  1. 0:07All right, so we're sharing the screen.
  2. 0:11All right, so um
  3. 0:14we are recording here.
  4. 0:18Let's go back here. So essentially
  5. 0:21you will need to go to GitHub.
  6. 0:38And then you will be in some kind of a
  7. 0:41repository.
  8. 0:43And when the repository is opened, it
  9. 0:46shows like a settings thing here. And
  10. 0:48then you go in there to configure. That
  11. 0:50doesn't take that long, but I can't
  12. 0:52display that cuz I'm signed out and
  13. 0:55I can't reset my password cuz my phone
  14. 0:58will not receive an email in this room.
  15. 1:01So um what we're going to do is
  16. 1:05we're just going to look at some
  17. 1:06examples of ONNX in the code
  18. 1:10essentially. So that we can do. So let's
  19. 1:13go to the homework.
  20. 1:15Your first neural networks.
  21. 1:18And let's look at the homework. Oh,
  22. 1:19sorry. You guys are not
  23. 1:21seeing this.
  24. 1:29Okay, so
  25. 1:31let's go back recap here. So we were
  26. 1:33here.
  27. 1:34We generated the ONNX file.
  28. 1:38Which are these from the models trained.
  29. 1:40Now you need to deploy it to a website.
  30. 1:44Okay.
  31. 1:45So to deploy it
  32. 1:47um I provided here
  33. 1:51you know, ONNX deployment examples. So
  34. 1:53you can click on this.
  35. 2:00Okay.
  36. 2:01And can see essentially
  37. 2:04um I have
  38. 2:07you know
  39. 2:09this real data run 10 index.html.
  40. 2:13So So here in this example, you're going
  41. 2:15to deploy it with HTML, CSS, and
  42. 2:18JavaScript. So that There's nothing new
  43. 2:21there.
  44. 2:22If you click on this
  45. 2:25essentially
  46. 2:27pretty standard HTML page. Notice
  47. 2:30there's some inputs.
  48. 2:32And then you would essentially
  49. 2:36um So imagine that you have a a model
  50. 2:39that takes four values, for instance,
  51. 2:41right? So that's the input. So you grab
  52. 2:44the values from those text boxes, you
  53. 2:46create the tensor of size four, you feed
  54. 2:49it through the model, the model
  55. 2:51predicts, and then you grab the
  56. 2:53predictions and you display them.
  57. 2:55That's it. So in the wine quality
  58. 2:57example, we had 11
  59. 3:00text boxes essentially. You would enter
  60. 3:01the values there, run them through the
  61. 3:04model, and it would predict what? The
  62. 3:06wine quality. Let's say six. And that's
  63. 3:09it. You just display the result. So in
  64. 3:12this example
  65. 3:14that's essentially
  66. 3:16the idea.
  67. 3:20There it is. So you can see here I
  68. 3:25I'm pressing run, right? And I get some
  69. 3:28values. Do you guys see that? So there's
  70. 3:31an ONNX model in the background.
  71. 3:34Takes in the four inputs and produces
  72. 3:38What is this? 1 2 3 4 5 6 7 outputs.
  73. 3:42It's a regression type of a
  74. 3:44application.
  75. 3:46Does this make sense?
  76. 3:47All right. Now the key insight is how do
  77. 3:50you build this? Well, this is just HTML
  78. 3:53text boxes and buttons, right?
  79. 3:56But you're going to and CSS if you want
  80. 3:59to make it pretty, but otherwise you
  81. 4:01need JavaScript and a JavaScript type
  82. 4:05library to be able to process the ONNX
  83. 4:08file. What do you have to do there? Grab
  84. 4:10the values from the text boxes, convert
  85. 4:14into a tensor, run it through the ONNX
  86. 4:16file, have the ONNX file predict, and
  87. 4:19then you grab that value and you display
  88. 4:21it back out to the website. Got it? Any
  89. 4:24questions on that?
  90. 4:26All right. So, let's take a look at this
  91. 4:28code. So, you've seen the application
  92. 4:30right? In this example. Now,
  93. 4:35um so, you can see here I'm using run
  94. 4:3810.
  95. 4:41Uh so, this one
  96. 4:44uh this is run 10, okay? So, we're in
  97. 4:45run 10 index.html.
  98. 4:48So, that's this file here, index.html.
  99. 4:51Notice there's a JS file, and then you
  100. 4:54have a couple of ONNX.
  101. 4:56So, what hap- what happened with this
  102. 4:57website, if you notice,
  103. 4:59because I have multiple buttons,
  104. 5:02I actually have a, you know, several
  105. 5:04ONNX models in there. And I'm just
  106. 5:07invoking all of them. You can see I have
  107. 5:09more over here.
  108. 5:11Um
  109. 5:12so, each time I run do one of those
  110. 5:14runs, I'm just calling a separate ONNX
  111. 5:17model. So, that's why say you you just
  112. 5:19have to do one.
  113. 5:21But, you know, this example has see one
  114. 5:23ONNX, another ONNX, another ONNX,
  115. 5:26another ONNX, another ONNX. Got it?
  116. 5:29So, then what do you need to do? Uh you
  117. 5:31have the end Let's start at the index
  118. 5:34page, probably.
  119. 5:35Um CSS
  120. 5:39is probably in the HTML file,
  121. 5:43if I remember correctly.
  122. 5:47Let's give it a minute. For some reason,
  123. 5:49this is taking a very long time.
  124. 6:03I think the reason why I forgot my
  125. 6:04password in GitHub is probably the last
  126. 6:07time I did a lecture like this. I reset
  127. 6:09it in another room.
  128. 6:11But here I can't I don't like it to
  129. 6:13connect my phone to the Wi-Fi, so
  130. 6:17anyway.
  131. 6:18Um let's do
  132. 6:22I don't know why this is taking too
  133. 6:26Let's go back.
  134. 6:28Click on index.html.
  135. 6:31All right, so this is the HTML. All
  136. 6:33right, so let's go through this one just
  137. 6:35to get a feel for how it works. So
  138. 6:37notice there is an index.js file. That's
  139. 6:41where you have your index logic. Notice
  140. 6:43this is the reason
  141. 6:45why you have to worry about that offset
  142. 6:48that I show you showed you. Because of
  143. 6:51the ORT ONNX runtime library that you
  144. 6:55will be importing, okay? So maybe this
  145. 6:58you know, I worked on this like last
  146. 7:00year. This is not even that old, but
  147. 7:03this these things are constantly being
  148. 7:05updated, okay? So
  149. 7:08if you have errors of it a compatibility
  150. 7:11error, that's how you can start to fix
  151. 7:13it is by figuring out that opt.
  152. 7:15But see, you have you have essentially
  153. 7:17the library for ONNX in JavaScript. You
  154. 7:19can see ort.js.
  155. 7:22And then after that um the HTML should
  156. 7:24be pretty straightforward.
  157. 7:26Uh you have essentially here you notice
  158. 7:28just I have a style sheet, so you can
  159. 7:30ignore this. This is just to make it
  160. 7:32more presentable. Then in the body you
  161. 7:35can see I have what? I have four text
  162. 7:39boxes.
  163. 7:40Right? And the four text boxes have like
  164. 7:43names box zero C1 C2 or box one C1 box
  165. 7:48two C1 box three C1. Notice I do put in
  166. 7:53default values. Please put in in your
  167. 7:55homework default values because that way
  168. 7:57I just have to click the button and get
  169. 7:59a result. If you leave that blank and it
  170. 8:03errors out, that's an automatic zero.
  171. 8:05But you know what I mean. Help me out,
  172. 8:07please, cuz I have to check all of your
  173. 8:10homework assignments, all right? So, put
  174. 8:12a default value in there,
  175. 8:14and then notice you put an input, and
  176. 8:16that's just a button,
  177. 8:18and notice it says on click run example
  178. 8:21one. So, you just need to define that
  179. 8:24function, right? And that's it. Okay? My
  180. 8:27My example is more complicated because I
  181. 8:30have multiple buttons for multiple uh
  182. 8:33ONNX files. I have a run example two.
  183. 8:37I have run example synthetic, run
  184. 8:39example Gen Hong. I have And then, you
  185. 8:43know, and that's it. Then the other
  186. 8:45thing you obviously need to have is you
  187. 8:47need to have a few divs in your HTML to
  188. 8:50display the results, right? So, in this
  189. 8:52case I have predictions one, predictions
  190. 8:55two, difference, prediction synthetic.
  191. 8:59So, when you finish the JavaScript,
  192. 9:01after you generate the output from the
  193. 9:03ONNX file, you will link that output to
  194. 9:06these variables and display the result.
  195. 9:09Got it?
  196. 9:10So, that's essentially
  197. 9:12uh it.
  198. 9:14Um I have a few more predictions here,
  199. 9:17and then I have multiple inputs, right?
  200. 9:19So, this is just for the other models.
  201. 9:21Multiple inputs.
  202. 9:23Uh and that's it. So, as you can see,
  203. 9:25the HTML HTML is pretty straightforward.
  204. 9:28Text boxes with default values, the
  205. 9:31input tying to some function, and then a
  206. 9:33div to display the results.
  207. 9:36Any questions on that part?
  208. 9:40All right. So, if you understand that,
  209. 9:41then the next step is to
  210. 9:44um
  211. 9:46look at
  212. 9:48this index.js.
  213. 9:51So, index.js is where you can define the
  214. 9:54run example one, or whatever it is,
  215. 9:57right? The function that invokes ONNX
  216. 9:59in this context. So, I'm going to click
  217. 10:02on run 10 again. I'm going to go to
  218. 10:03index.js,
  219. 10:06and you can see here it is.
  220. 10:08So, essentially, you will use something
  221. 10:10like async function run example one.
  222. 10:13And that's the function that will handle
  223. 10:16one button.
  224. 10:17Do you see that? If you scroll down,
  225. 10:20you'll see
  226. 10:22that then there's run example forward.
  227. 10:25So, if you do that's another example,
  228. 10:28another button. So, yours only needs to
  229. 10:31have one async. Got it? One of these
  230. 10:34functions to handle the pressing of a
  231. 10:36button. So, you can see here I have
  232. 10:38multiple
  233. 10:40things, but I still like to show you
  234. 10:42this code because I each of those
  235. 10:46functions handle something different, so
  236. 10:48you can scroll through them and find the
  237. 10:50one that's most appropriate to your
  238. 10:52problem, okay? So, that's what I would
  239. 10:55recommend.
  240. 10:56All right. So, now let's just take a
  241. 10:58look
  242. 10:59at one of them. So, I think run example
  243. 11:02homework one might be a good one.
  244. 11:05So, notice here
  245. 11:06what needs to happen, right? So,
  246. 11:08essentially,
  247. 11:10you you know, somebody presses the
  248. 11:12button run example heart, you know, HW1,
  249. 11:16you create a variable X, right?
  250. 11:20And th- this one is a float 32 of size
  251. 11:22four. If I was using wine quality, it
  252. 11:25would be size 11.
  253. 11:27Right? So, that you have to change that.
  254. 11:30It needs to match your dummy input when
  255. 11:32you exported the ONNX model.
  256. 11:34Then, this is pretty straightforward,
  257. 11:36document.get element by ID, and you grab
  258. 11:39the values in the text boxes. And you
  259. 11:42assign them to X as X0, X1, X2, X3.
  260. 11:46Then notice in my example, I'm using
  261. 11:48ORT, ONNX runtime, right? The offset
  262. 11:52version,
  263. 11:53right? But, that part I leave it to you
  264. 11:55guys to figure out. Hopefully, this will
  265. 11:58be the easiest approach. Notice you have
  266. 12:00to spec- This is where
  267. 12:03you start to go from JavaScript
  268. 12:05variables
  269. 12:06to torch type variables that will fit in
  270. 12:11ONNX.
  271. 12:13So, uh so, TensorFlow, for instance,
  272. 12:16they have their own approach of doing
  273. 12:19this, but it's all TensorFlow. Whereas,
  274. 12:21ONNX was developed by Microsoft, I
  275. 12:24believe, and it's the the first letter
  276. 12:26in ONNX is open. So, it's supposed to be
  277. 12:29an open
  278. 12:31uh format for multiple types of
  279. 12:33frameworks.
  280. 12:35So, anyway, so we instantiate the tensor
  281. 12:38to be a 1 {comma} 4. So, that's the
  282. 12:41dummy input again. What gets mapped to
  283. 12:43it? X. You can see that, X. And that
  284. 12:46creates tensor X. So, essentially, you
  285. 12:49have your data, your input from your
  286. 12:51text boxes,
  287. 12:52and then essentially, you just Notice
  288. 12:55here, you do ORT inference inference
  289. 12:59session.create.
  290. 13:01And what do you grab? You grab the
  291. 13:02inverse Sorry, the ONNX file that you
  292. 13:06exported from Colab or Anaconda.
  293. 13:10Does this make sense?
  294. 13:11Now, this little date now plus date now
  295. 13:14that I added here is because GitHub
  296. 13:17loves or GitHub pages loves to cache
  297. 13:20things. And so, it updates like every 10
  298. 13:24minutes. So, if you do the date now,
  299. 13:26it'll grab the latest. Otherwise, you'll
  300. 13:28see that you update your you put in a
  301. 13:30new ONNX, and then when you run, it's
  302. 13:32still using the old one. Cuz it takes
  303. 13:34about 10 minutes to update. So,
  304. 13:36when you're debugging,
  305. 13:38it'll frustrate you a lot. So, use the
  306. 13:40date.
  307. 13:41Um once the session is created, you have
  308. 13:44the ONNX tied, then you just do
  309. 13:46session.run, you give it the input, and
  310. 13:49boom, results. You're done. So, the
  311. 13:51model has now predicted, and it'll be
  312. 13:54one value for the wine quality, for
  313. 13:56instance, or you know, however you do
  314. 13:58it.
  315. 14:00And then from results, you take out
  316. 14:02output one. Remember that output one
  317. 14:04that we defined? {dot} data, okay? And
  318. 14:07now you have your data.
  319. 14:10Your results. And now, notice what you
  320. 14:12do, prediction. This is the div in your
  321. 14:14HTML. Get element by ID, you grab it as
  322. 14:18predictions, and then usually divs will
  323. 14:21have this property called inner HTML,
  324. 14:24and then you can just set that up.
  325. 14:27Right? And provide your result. Got it?
  326. 14:30So, in in this example, this is
  327. 14:32especially useful because my output
  328. 14:35it was a vector of seven values. So, I
  329. 14:38had to take out each of the values and
  330. 14:40display it properly with a label and
  331. 14:42everything to know what everything was.
  332. 14:45If you were just doing one, then you
  333. 14:46know, it might be
  334. 14:48easier.
  335. 14:49So, you can see that here. Uh we just
  336. 14:51grab from output output zero, output
  337. 14:56one, output two.
  338. 14:58You can uh round to two decimal places,
  339. 15:01and then you just display
  340. 15:04in the if this is a table. So, you
  341. 15:06create a table dynamically in HTML.
  342. 15:09That's it, guys. That's essentially the
  343. 15:11whole thing. The only thing I wasn't
  344. 15:14able to show you, unfortunately, and I'm
  345. 15:15sorry about that, is the the
  346. 15:18Once you add Notice that these files are
  347. 15:21just added to a folder
  348. 15:23in GitHub, right? This is a regular
  349. 15:25GitHub repo.
  350. 15:27But the thing is
  351. 15:29GitHub Pages is like a feature that's
  352. 15:32not enabled by default.
  353. 15:35You have to enable it. And so,
  354. 15:38I have to go into this repo and enable
  355. 15:41GitHub Pages.
  356. 15:43And it's pretty easy, but you just have
  357. 15:45to enable it. And I I'm not logged in
  358. 15:47right now.
  359. 15:48Do you have a question?
  360. 15:50>> I was going to say, do you want me to
  361. 15:52like show my GitHub Pages stuff?
  362. 15:54>> Yes.
  363. 15:55Do that, please.
  364. 15:59Yes, exactly. Thank you.
  365. 16:01I really appreciate that.
  366. 16:05Let's end this one here. So,
  367. 16:08Taylor is going to
  368. 16:11uh demo for us, okay? So, I'm going to
  369. 16:13end this one.

About this transcript

This page contains the full transcript of ML Regression - Linear regression, MLPs, DL nets, Linear Plus Non-Linear, XGBoost, ONNX (part 3) by Ricardo Calix, generated from the public captions YouTube serves with the video. The transcript has 2,250 words across 369 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.