[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003e\u003cstrong\u003eDeprecated:\u003c/strong\u003e This guide is outdated and uses datasets/methods that may be removed; refer to Vertex AI example workflows instead.\u003c/p\u003e\n"],["\u003cp\u003eThis page provides TensorFlow with Earth Engine example workflows using the Earth Engine Python API and Colab Notebooks.\u003c/p\u003e\n"],["\u003cp\u003eUsing these workflows may incur costs for Google Cloud services like AI Platform and Cloud Storage.\u003c/p\u003e\n"],["\u003cp\u003eThe workflows cover various machine learning techniques, including DNNs, hostable DNN prediction, logistic regression, and FCNNs.\u003c/p\u003e\n"],["\u003cp\u003eTraining large models may require using AI Platform for extended training jobs and efficient prediction deployment.\u003c/p\u003e\n"]]],[],null,["# TensorFlow example workflows\n\n| **Deprecated!** This guide uses datasets that may be removed from the\n| Earth Engine catalog and/or methods that may be removed in future versions of the Earth\n| Engine API. See [Vertex AI example workflows](/earth-engine/guides/ml_examples) instead.\n\n\nThis page has example workflows to demonstrate uses of TensorFlow with Earth Engine. See\n[the TensorFlow page](/earth-engine/guides/tensorflow) for more details. These examples are\nwritten using the [Earth Engine Python API](/earth-engine/guides/python_install) and TensorFlow\nrunning in [Colab Notebooks](https://colab.research.google.com/).\n\nCosts\n-----\n\n| **Warning!** These guides use billable components of Google Cloud including:\n|\n| - AI Platform Training ([pricing](https://cloud.google.com/ai-platform/training/pricing))\n| - AI Platform Prediction ([pricing](https://cloud.google.com/ai-platform/prediction/pricing))\n| - Cloud Storage ([pricing](https://cloud.google.com/storage/pricing))\n|\n| You can use the\n| [Pricing Calculator](https://cloud.google.com/products/calculator) to generate\n| a cost estimate based on your projected usage.\n\nMulti-class prediction with a DNN\n---------------------------------\n\n\nA \"deep\" neural network (DNN) is simply an artificial neural network (ANN) with one or more\nhidden layers. This example demonstrates a very simple DNN with a single hidden layer. The\nDNN takes spectral vectors as inputs (i.e. one pixel at a time) and outputs a single class\nlabel and class probabilities per pixel. The Colab notebook below demonstrates creating\nthe DNN, training it with data from Earth Engine, making predictions on exported imagery and\nimporting the predictions to Earth Engine. \n\n|---------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/TF_demo1_keras.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/TF_demo1_keras.ipynb) |\n\nHostable DNN for prediction in Earth Engine\n-------------------------------------------\n\n\nTo get predictions from your trained model directly in Earth Engine (e.g. in the\n[Code Editor](/earth-engine/guides/playground)), you need to host the model\non [Google AI Platform.](https://cloud.google.com/ai-platform) This guide\ndemonstrates how to save a trained model in\n[`SavedModel`](https://cloud.google.com/ml-engine/docs/tensorflow/exporting-for-prediction)\nformat, prepare the model for hosting with the `earthengine model prepare`\ncommand, and get predictions in Earth Engine interactively with\n`ee.Model.fromAiPlatformPredictor`. \n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/Earth_Engine_TensorFlow_AI_Platform.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/Earth_Engine_TensorFlow_AI_Platform.ipynb) |\n\nLogistic regression the TensorFlow way\n--------------------------------------\n\n\nClassical machine learning methods such as logistic regression are natural to implement\nin TensorFlow. This notebook demonstrates a logistic regression based deforestation\ndetector from before and after annual composites. Note that this very simplistic model\nis just for demonstration purposes; add a few hidden layers for higher accuracy. \n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/Earth_Engine_TensorFlow_logistic_regression.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/Earth_Engine_TensorFlow_logistic_regression.ipynb) |\n\nRegression with an FCNN\n-----------------------\n\n\nA \"convolutional\" neural network (CNN) contains one or more convolutional layers, in which\ninputs are neighborhoods of pixels, resulting in a network that is not fully-connected, but\nis suited to identifying spatial patterns. A fully convolutional neural network (FCNN) does\nnot contain a fully-connected layer as output. This means that it does not learn a global\noutput (i.e. a single output per image), but rather localized outputs (i.e. per-pixel).\n\nThis Colab notebook demonstrates the use of the\n[UNET model](https://arxiv.org/abs/1505.04597), an FCNN developed for medical\nimage segmentation, for predicting a continuous \\[0,1\\] output in each pixel from 256x256\nneighborhoods of pixels. Specifically, this example shows how to export patches of data to\ntrain the network and how to overtile image patches for inference, to eliminate tile boundary\nartifacts. \n\n|---------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/UNET_regression_demo.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/UNET_regression_demo.ipynb) |\n\nTraining on AI Platform\n-----------------------\n\n\nFor relatively large models (like the FCNN example), the longevity of the free virtual\nmachine on which Colab notebooks run may not be sufficient for a long-running training\njob. Specifically, if the expected prediction error is not minimized on the evaluation\ndataset, then more training iterations may be prudent. For performing large training\njobs in the Cloud, this Colab notebook demonstrates how to\n[package your training\ncode](https://cloud.google.com/ml-engine/docs/packaging-trainer), [start a\ntraining job](https://cloud.google.com/ml-engine/docs/training-jobs), prepare a\n[`SavedModel`](https://cloud.google.com/ml-engine/docs/tensorflow/exporting-for-prediction)\nwith the `earthengine model prepare` command, and get predictions in Earth\nEngine interactively with `ee.Model.fromAiPlatformPredictor`. \n\n|-----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/AI_platform_demo.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/AI_platform_demo.ipynb) |"]]