Skip to Content
深度學習|內行人的做法
book

深度學習|內行人的做法

by Josh Patterson, Adam Gibson
January 2019
Beginner to intermediate
576 pages
14h 31m
Chinese
GoTop Information, Inc.
Content preview from 深度學習|內行人的做法
建立輸入向量
|
495
向量化的簡單範例
接下來的程式碼,希望能以簡單的方式,展現出一些設定特徵與標籤相關
的基本概念。在實務上,其實還存在其他可能更有效的 ND4J 方法。很多
時候,專業工作者會透過 DL4J 的資料讀取器,以人工方式執行大多數這
方面的工作。我們在這裡只是想展示一下,如何以實際的方式,來處理資
料的一種做法。
建立向量的基礎知識
我們首先創建一個帶有兩列(column)的簡單特徵向量,如下所示:
INDArray myFeatures = ND4j.create(new float[]{0.5, 0.5},new int[]{1,2});
調整向量大小
我們可以使用
ND4j.create()
方法的第二個參數,來控制向量的大小:
new int[]{1,2}
這個參數會指示 ND4J 去創建一個具有兩個特徵列的單行 NDArray
設定特徵值
有很多種方法可以設定特徵值。在下面的程式碼片段中,我們展示了以人工方式設定向
量中特徵值最簡單的方法:
for ( int row = 0; row < myFeatures.rows(); row++ ) {
for ( int col = 0; col < myFeatures.getRow( row ).columns(); col++ ) {
myFeatures.getRow(row).putScalar(col, 0.9);
}
}
在這個例子中,我們把每一行中的每一列都設為 0.9
設定標籤值
設定標籤值與設定特徵值一樣簡單,因為輸入特徵資料與輸出標籤資料都使用相同的資 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

高效能網站建置指南

高效能網站建置指南

Steve Souders
初探深度學習|使用TensorFlow

初探深度學習|使用TensorFlow

Reza Zadeh, Bharath Ramsundar
深度学习实战

深度学习实战

Douwe Osinga

Publisher Resources

ISBN: 9789865020262