리뷰 Keras Functional API를 사용하여 DNN 빌드하기개

리뷰 11266개

Rohit N. · 대략 4년 전에 리뷰됨

Manuel F. · 대략 4년 전에 리뷰됨

Jakob T. · 대략 4년 전에 리뷰됨

合田通 合. · 대략 4년 전에 리뷰됨

Subodh G. · 대략 4년 전에 리뷰됨

Craig H. · 대략 4년 전에 리뷰됨

Elizabeth C. · 대략 4년 전에 리뷰됨

Danyal F. · 대략 4년 전에 리뷰됨

Saheb N. · 대략 4년 전에 리뷰됨

Casey D. · 대략 4년 전에 리뷰됨

Arkadiusz C. · 대략 4년 전에 리뷰됨

Raul G. · 대략 4년 전에 리뷰됨

Cheon S. · 대략 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.

Louis-Philippe R. · 대략 4년 전에 리뷰됨

Jarosław L. · 대략 4년 전에 리뷰됨

Fabrice S. · 대략 4년 전에 리뷰됨

Aliya A. · 대략 4년 전에 리뷰됨

Yepeng S. · 대략 4년 전에 리뷰됨

Edwin C. · 대략 4년 전에 리뷰됨

Mattia M. · 대략 4년 전에 리뷰됨

Ming Sheng C. · 대략 4년 전에 리뷰됨

Alexander K. · 대략 4년 전에 리뷰됨

Lincoln A. · 대략 4년 전에 리뷰됨

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

Juan B. · 대략 4년 전에 리뷰됨

sai krishna A. · 대략 4년 전에 리뷰됨

Google은 게시된 리뷰가 제품을 구매 또는 사용한 소비자에 의해 작성되었음을 보증하지 않습니다. 리뷰는 Google의 인증을 거치지 않습니다.