![]() ![]() In general, if an object can be converted to a tensor with tf.convert_to_tensor it can be passed anywhere you can pass a tf.Tensor. To convert it to a tensor, use tf.convert_to_tensor: tf.convert_to_tensor(numeric_features) The DataFrame can be converted to a NumPy array using the DataFrame.values property or numpy.array(df). Take the numeric features from the dataset (skip the categorical features for now): numeric_feature_names = This works because the pandas.DataFrame class supports the _array_ protocol, and TensorFlow's tf.convert_to_tensor function accepts objects that support the protocol. If your data has a uniform datatype, or dtype, it's possible to use a pandas DataFrame anywhere you could use a NumPy array. You will build models to predict the label contained in the target column. This is what the data looks like: df.head() Read the CSV file using pandas: df = pd.read_csv(csv_file) If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.ĭownload the CSV file containing the heart disease dataset: csv_file = tf._file('heart.csv', '')ġ3273/13273 - 0s 0us/step 03:22:26.434006: W tensorflow/compiler/tf2tensorrt/utils/py_:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. 03:22:26.433996: W tensorflow/compiler/xla/stream_executor/platform/default/dso_:64] Could not load dynamic library 'libnvinfer_plugin.so.7' dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory 03:22:26.433900: W tensorflow/compiler/xla/stream_executor/platform/default/dso_:64] Could not load dynamic library 'libnvinfer.so.7' dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory Read data using pandas import pandas as pd You will use this information to predict whether a patient has heart disease, which is a binary classification task. Each row describes a patient, and each column describes an attribute. ![]() There are several hundred rows in the CSV. You will use a small heart disease dataset provided by the UCI Machine Learning Repository. This tutorial provides examples of how to load pandas DataFrames into TensorFlow. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |