Google Earth Engine(GEE)——TensorFlow支持深度學(xué)習(xí)等高級(jí)機(jī)器學(xué)習(xí)方法(非免費(fèi)項(xiàng)目)
TensorFlow 和地球引擎
TensorFlow是一個(gè)開源機(jī)器學(xué)習(xí)平臺(tái),支持深度學(xué)習(xí)等高級(jí)機(jī)器學(xué)習(xí)方法。本頁(yè)面介紹了 Earth Engine 中的 TensorFlow 特定功能。盡管 TensorFlow 模型是在 Earth Engine 之外開發(fā)和訓(xùn)練的,但 Earth Engine API 提供了以 TFRecord 格式導(dǎo)出訓(xùn)練和測(cè)試數(shù)據(jù)以及以 TFRecord 格式導(dǎo)入/導(dǎo)出圖像的方法。有關(guān)如何開發(fā)管道以將 TensorFlow 與 Earth Engine 中的數(shù)據(jù)結(jié)合使用的更多信息,請(qǐng)參閱?TensorFlow 示例頁(yè)面。請(qǐng)參閱?TFRecord 頁(yè)面以了解有關(guān) Earth Engine 如何將數(shù)據(jù)寫入 TFRecord 文件的更多信息。
ee.Model
該ee.Model包處理與 TensorFlow 支持的機(jī)器學(xué)習(xí)模型的交互。
與 AI Platform 上托管的模型交互
ee.Model.fromAiPlatformPredictor(projectName,?projectId,?modelName,?version,?region,?inputProperties,?inputTypeOverride,?inputShapes,?proj,?fixInputProj,?inputTileSize,?inputOverlapSize,?outputTileSize,?outputBands,?outputProperties,?outputMultiplier)
Returns an ee.Model from a description of an AI Platform prediction model. (See?https://cloud.google.com/ml-engine/).
Arguments:
projectName (Object, default: null):
The Google Cloud project that owns the model. Deprecated: use "projectId" instead.
projectId (String, default: null):
The ID of the Google Cloud project that owns the model.
modelName (String, default: null):
The name of the model.
version (String, default: null):
The model version. Defaults to the AI Platform default model version.
region (String, default: null):
The model deployment region. Defaults to "us-central1".
inputProperties (List, default: null):
Properties passed with each prediction instance. Image predictions are tiled, so these properties will be replicated into each image tile instance. Defaults to no properties.
inputTypeOverride (Dictionary, default: null):
Types to which model inputs will be coerced if specified. Both Image bands and Image/Feature properties are valid.
inputShapes (Dictionary, default: null):
The fixed shape of input array bands. For each array band not specified, the fixed array shape will be automatically deduced from a non-masked pixel.
proj (Projection, default: null):
The input projection at which to sample all bands. Defaults to the default projection of an image's first band.
fixInputProj (Boolean, default: null):
If true, pixels will be sampled in a fixed projection specified by 'proj'. The output projection is used otherwise. Defaults to false.
inputTileSize (List, default: null):
Rectangular dimensions of pixel tiles passed in to prediction instances. Required for image predictions.
inputOverlapSize (List, default: null):
Amount of adjacent-tile overlap in X/Y along each edge of pixel tiles passed in to prediction instances. Defaults to [0, 0].
outputTileSize (List, default: null):
Rectangular dimensions of pixel tiles returned from AI Platform. Defaults to the value in 'inputTileSize'.
outputBands (Dictionary, default: null):
A map from output band names to a dictionary of output band info. Valid band info fields are 'type' and 'dimensions'. 'type' should be a ee.PixelType describing the output band, and 'dimensions' is an optional integer with the number of dimensions in that band e.g.: "outputBands: {'p': {'type': ee.PixelType.int8(), 'dimensions': 1}}". Required for image predictions.
outputProperties (Dictionary, default: null):
A map from output property names to a dictionary of output property info. Valid property info fields are 'type' and 'dimensions'. 'type' should be a ee.PixelType describing the output property, and 'dimensions' is an optional integer with the number of dimensions for that property if it is an array e.g.: "outputBands: {'p': {'type': ee.PixelType.int8(), 'dimensions': 1}}". Required for predictions from FeatureCollections.
outputMultiplier (Float, default: null):
An approximation to the increase in data volume for the model outputs over the model inputs. If specified this must be >= 1. This is only needed if the model produces more data than it consumes, e.g. a model that takes 5 bands and produces 10 outputs per pixel.
Returns: Model
ee.Model可以創(chuàng)建?一個(gè)新實(shí)例?ee.Model.fromAiPlatformPredictor()。這是一個(gè)ee.Model將 Earth Engine 數(shù)據(jù)打包成張量的對(duì)象,將它們作為預(yù)測(cè)請(qǐng)求轉(zhuǎn)發(fā)到?Google AI Platform,然后自動(dòng)將響應(yīng)重新組合為 Earth Engine 數(shù)據(jù)類型。請(qǐng)注意,根據(jù)模型及其輸入的大小和復(fù)雜性,您可能希望?調(diào)整AI Platform 模型的最小節(jié)點(diǎn)大小以適應(yīng)大量預(yù)測(cè)。
Earth Engine 要求 AI Platform 模型使用 TensorFlow 的?SavedModel?格式。在托管模型可以與地球引擎交互之前,其輸入/輸出需要與 TensorProto 交換格式兼容,特別是在 base64 中序列化的 TensorProtos。為model prepare簡(jiǎn)化此操作,Earth Engine CLI 具有?將現(xiàn)有 SavedModel 包裝在所需操作中以轉(zhuǎn)換輸入/輸出格式的命令。
要將模型與 一起使用ee.Model.fromAiPlatformPredictor(),您必須具有足夠的權(quán)限才能使用該模型。具體來(lái)說(shuō),您(或使用該模型的任何人)至少需要?ML Engine Model User 角色。您可以從Cloud Console的模型頁(yè)面檢查和設(shè)置模型權(quán)限?。
地區(qū)
您應(yīng)該為模型使用區(qū)域端點(diǎn),在模型創(chuàng)建、版本創(chuàng)建和ee.Model.fromAiPlatformPredictor().?任何區(qū)域都可以工作(不要使用全局),但us-central1首選。不要指定?REGIONS參數(shù)。如果您是從Cloud Console創(chuàng)建模型?,請(qǐng)確保選中區(qū)域框。
費(fèi)用
警告!這些指南使用 Google Cloud 的計(jì)費(fèi)組件,包括:
AI Platform Training(定價(jià))
AI 平臺(tái)預(yù)測(cè)(定價(jià))
云存儲(chǔ)(定價(jià))
您可以使用?定價(jià)計(jì)算器根據(jù)您的預(yù)計(jì)使用情況生成成本估算。
圖像預(yù)測(cè)
predictImage(image)
Make predictions from pixel tiles of an image. The predictions are merged as bands with the input image.
The model will receive 0s in place of masked pixels. The masks of predicted output bands are the minimum of the masks of the inputs.
Arguments:
this:model (Model)
image (Image):
The input image.
Returns: Image
用于model.predictImage()對(duì)ee.Image?使用托管模型進(jìn)行預(yù)測(cè)。的返回類型predictImage()是 an?ee.Image,可以添加到地圖、用于其他計(jì)算、導(dǎo)出等。Earth Engine 將自動(dòng)平鋪輸入波段并根據(jù)需要調(diào)整輸出投影以進(jìn)行比例更改和覆蓋。(有關(guān)平鋪工作原理的更多信息,請(qǐng)參閱?TFRecord 文檔)。請(qǐng)注意,即使帶是標(biāo)量(最后一個(gè)維度將為 1),地球引擎也會(huì)始終將 3D 張量轉(zhuǎn)發(fā)到您的模型。
幾乎所有的卷積模型都有一個(gè)固定的輸入投影(模型訓(xùn)練的數(shù)據(jù)的投影)。在這種情況下,請(qǐng)?jiān)谡{(diào)用 時(shí)將fixInputProj參數(shù)設(shè)置為trueee.Model.fromAiPlatformPredictor()。在可視化預(yù)測(cè)時(shí),在縮小具有固定輸入投影的模型時(shí)要小心。這與此處描述的原因相同。具體而言,縮放到較大的空間范圍可能會(huì)導(dǎo)致請(qǐng)求過(guò)多數(shù)據(jù),并可能表現(xiàn)為 AI Platform 速度減慢或拒絕。
TensorFlow 機(jī)器學(xué)習(xí) 深度學(xué)習(xí)
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。