Keras Functional API を使用して DNN を構築する のレビュー

11266 件のレビュー

Narain Rohit · 約4年前にレビュー済み

Freude Manuel · 約4年前にレビュー済み

Torgander Jakob · 約4年前にレビュー済み

合田通 合田通 · 約4年前にレビュー済み

Ganguly Subodh · 約4年前にレビュー済み

Holliman Craig · 約4年前にレビュー済み

Chan Elizabeth · 約4年前にレビュー済み

Floisand Danyal · 約4年前にレビュー済み

Nag Saheb · 約4年前にレビュー済み

Dye Casey · 約4年前にレビュー済み

Chadzynski Arkadiusz · 約4年前にレビュー済み

Gomes Fernandes Raul · 約4年前にレビュー済み

Seonwoo Cheon · 約4年前にレビュー済み

Python 3 Build a DNN using the Keras Functional API Learning objectives Review how to read in CSV file data using tf.data Specify input, hidden, and output layers in the DNN architecture Review and visualize the final DNN shape Train the model locally and visualize the loss curves Deploy and predict with the model using Cloud AI Platform In this notebook, we will build a Keras DNN to predict the fare amount for NYC taxi cab rides. Each learning objective will correspond to a #TODO in this student lab notebook -- try to complete this notebook first and then review the solution notebook. import os, json, math import numpy as np import shutil import tensorflow as tf print("TensorFlow version: ",tf.version.VERSION) ​ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # SET TF ERROR LOG VERBOSITY TensorFlow version: 2.6.0 Locating the CSV files We will start with the CSV files that we wrote out in the first notebook of this sequence. Just so you don't have to run the notebook, we saved a copy in ../../data !ls -l ../data/*.csv -rw-r--r-- 1 jupyter jupyter 2186310 Nov 17 20:47 ../data/taxi-traffic-test.csv -rw-r--r-- 1 jupyter jupyter 9713118 Nov 17 20:47 ../data/taxi-traffic-train.csv -rw-r--r-- 1 jupyter jupyter 2036826 Nov 17 20:47 ../data/taxi-traffic-valid.csv Lab Task 1: Use tf.data to read the CSV files We wrote these cells in the third notebook of this sequence where we created a data pipeline with Keras. First let's define our columns of data, which column we're predicting for, and the default values. CSV_COLUMNS = ['fare_amount', 'pickup_datetime', 'pickup_longitude', 'pickup_latitude', 'dropoff_longitude', 'dropoff_latitude', 'passenger_count', 'key'] LABEL_COLUMN = 'fare_amount' DEFAULTS = [[0.0],['na'],[0.0],[0.0],[0.0],[0.0],[0.0],['na']] Next, let's define our features we want to use and our label(s) and then load in the dataset for training. def features_and_labels(row_data): for unwanted_col in ['pickup_datetime', 'key']: row_data.pop(unwanted_col) label = row_data.pop(LABEL_COLUMN) return row_data, label # features, label ​ # load the training data def load_dataset(pattern, batch_size=1, mode=tf.estimator.ModeKeys.EVAL): dataset = (tf.data.experimental.make_csv_dataset(pattern, batch_size, CSV_COLUMNS, DEFAULTS) .map(features_and_labels) # features, label ) if mode == tf.estimator.ModeKeys.TRAIN: dataset = dataset.shuffle(1000).repeat() dataset = dataset.prefetch(1) # take advantage of multi-threading; 1=AUTOTUNE return dataset --------------------------------------------------------------------------- AlreadyExistsError Traceback (most recent call last) /tmp/ipykernel_27156/3116940491.py in <module> 6 7 # load the training data ----> 8 def load_dataset(pattern, batch_size=1, mode=tf.estimator.ModeKeys.EVAL): 9 dataset = (tf.data.experimental.make_csv_dataset(pattern, batch_size, CSV_COLUMNS, DEFAULTS) 10 .map(features_and_labels) # features, label /opt/conda/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py in __getattr__(self, item) 60 61 def __getattr__(self, item): ---> 62 module = self._load() 63 return getattr(module, item) 64 /opt/conda/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py in _load(self) 43 """Load the module and insert it into the parent's globals.""" 44 # Import the target module and insert it into the parent's namespace ---> 45 module = importlib.import_module(self.__name__) 46 self._parent_module_globals[self._local_name] = module 47 /opt/conda/lib/python3.7/importlib/__init__.py in import_module(name, package) 125 break 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level) 128 129 /opt/conda/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _gcd_import(name, package, level) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _find_and_load(name, import_) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _load_unlocked(spec) /opt/conda/lib/python3.7/importlib/_bootstrap_external.py in exec_module(self, module) /opt/conda/lib/python3.7/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds) /opt/conda/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/api/__init__.py in <module> 8 import sys as _sys 9 ---> 10 from tensorflow_estimator.python.estimator.api._v1 import estimator 11 12 del _print_function /opt/conda/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py in <module> 8 import sys as _sys 9 ---> 10 from tensorflow_estimator.python.estimator.api._v1.estimator import experimental 11 from tensorflow_estimator.python.estimator.api._v1.estimator import export 12 from tensorflow_estimator.python.estimator.api._v1.estimator import inputs /opt/conda/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/experimental/__init__.py in <module> 8 import sys as _sys 9 ---> 10 from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder 11 from tensorflow_estimator.python.estimator.canned.kmeans import KMeansClustering as KMeans 12 from tensorflow_estimator.python.estimator.canned.linear import LinearSDCA /opt/conda/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/canned/dnn.py in <module> 25 from tensorflow.python.framework import ops 26 from tensorflow.python.util.tf_export import estimator_export ---> 27 from tensorflow_estimator.python.estimator import estimator 28 from tensorflow_estimator.python.estimator.canned import head as head_lib 29 from tensorflow_estimator.python.estimator.canned import optimizers /opt/conda/lib/python3.7/site-packages/tensorflow_estimator/python/estimator/estimator.py in <module> 60 ['features', 'labels', 'mode', 'params', 'self', 'config']) 61 _estimator_api_gauge = monitoring.BoolGauge('/tensorflow/api/estimator', ---> 62 'estimator api usage', 'method') 63 64 _canned_estimator_api_gauge = monitoring.StringGauge( /opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/monitoring.py in __init__(self, name, description, *labels) 359 """ 360 super(BoolGauge, self).__init__('BoolGauge', _bool_gauge_methods, --> 361 len(labels), name, description, *labels) 362 363 def get_cell(self, *labels): /opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/monitoring.py in __init__(self, metric_name, metric_methods, label_length, *args) 133 self._metric_name, len(self._metric_methods))) 134 --> 135 self._metric = self._metric_methods[self._label_length].create(*args) 136 137 def __del__(self): AlreadyExistsError: Another metric with the same name already exists.

Roux Louis-Philippe · 約4年前にレビュー済み

Lesisz Jarosław · 約4年前にレビュー済み

Signin Fabrice · 約4年前にレビュー済み

Ali Aliya · 約4年前にレビュー済み

Sun Yepeng · 約4年前にレビュー済み

Chuy (edchuy) Edwin · 約4年前にレビュー済み

Mancassola Mattia · 約4年前にレビュー済み

Choo Ming Sheng · 約4年前にレビュー済み

Klebanov Alexander · 約4年前にレビュー済み

Anderson Lincoln · 約4年前にレビュー済み

This error was always appearing " AttributeError: module 'tensorflow.tools.docs.doc_controls' has no attribute 'inheritable_header'"

Beltran Juan · 約4年前にレビュー済み

Ambati sai krishna · 約4年前にレビュー済み

公開されたレビューが、製品を購入または使用した人によるものであることは保証されません。Google はこれらのレビューの検証を行っていません。