All the code can be found in the chapter folders. You can run these code files on cloud platforms like Google Colab or your local machine. Note that some chapters require a GPU to run in a reasonable amount of time, so we recommend one of the cloud platforms as they come pre-installed with CUDA.
Running on a cloud platform
To run the notebook (.ipynb) files on a cloud platform, just click on one of the badges in the table below:
Chapter
Colab
Kaggle
Gradient
StudioLab
02 Regression and Classification
logistic_regression_using_keras_API.ipynb
multiple_linear_regression_using_keras_API.ipynb
simple_linear_regression.ipynb
simple_linear_regression_using_keras_API.ipynb
07 Unsupervised Learning
DBN.ipynb
PCA.ipynb
k_means_using_tensorflow.ipynb
restricted_boltzmann_machines.ipynb
som.ipynb
08 Autoencoders
ConvolutionAutoencoder.ipynb
DenoisingAutoencoder.ipynb
SparseAutoEncoder.ipynb
VAE.ipynb
VanillaAutoEncoder.ipynb
sentence_vector_gen.ipynb
09 Generative Models
CycleGAN_TF2.ipynb
DCGAN.ipynb
VanillaGAN.ipynb
11 Reinforcement Learning
DQNCartPole.ipynb
DQN_Atari_v2.ipynb
Introduction_to_gym.ipynb
random_agent_playing.ipynb
12 Probabilistic TensorFlow
AleatoryUncertainity_using_TFP.ipynb
Bayesian_networks.ipynb
EpistemicUncertainity_using_TFP.ipynb
Fun_with_tensorflow_probability.ipynb
Introduction_to_TFP.ipynb
16 Other Useful Deep Learning Libraries
H2o_classification.ipynb
PyTorch.ipynb
19 TensorFlow 2 Ecosystem
End_to_End_TFDS_pipeline.ipynb
Image_Classification_TF_Hub.ipynb
Introduction_to_TensorFlow_datasets.ipynb
Download a free PDF
If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost. Simply click on the link to claim your free PDF.
i use jupyterlab to run the script seq2seq_with_attn.py (converted to .ipny)
in the function
sents_en, sents_fr_in, sents_fr_out = download_and_read(download_url, num_sent_pairs=NUM_SENT_PAIRS)
there is reported error
UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in position 555: illegal multibyte sequence
i check on web and find that, it needs to add encoding="utf-8" for the line
with open(local_file, "r") as fin:
however, after done that, there is another bug reported in the line
en_sent, fr_sent = line.strip().split('\t')
ValueError: too many values to unpack (expected 2)
the first read line is as
['Go.',
'Va !',
'CC-BY 2.0 (France) Attribution: tatoeba.org #2877272 (CM) & #1158250 (Wittydev)']
so only two returned values en_sent, fr_sent are not enough
history = model.fit(x=train_features,y=train_labels, epochs=100, verbose=1, validation_split=0.2)
ValueError Traceback (most recent call last)
/root/repos/Deep-Learning-with-TensorFlow-and-Keras-3rd-edition/Chapter_2/multiple_linear_regression_using_keras_API.ipynb Cell 13 line 1
----> 1 history = model.fit(x=train_features,y=train_labels, epochs=100, verbose=1, validation_split=0.2)
File /usr/local/lib/python3.11/dist-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs) 67 filtered_tb = _process_traceback_frames(e.traceback) 68 # To get the full stack trace, call: 69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None 71 finally: 72 del filtered_tb
File /usr/local/lib/python3.11/dist-packages/keras/src/engine/data_adapter.py:1776, in train_validation_split(arrays, validation_split) 1774 unsplitable = [type(t) for t in flat_arrays if not _can_split(t)] 1775 if unsplitable:
-> 1776 raise ValueError( 1777 "validation_split is only supported for Tensors or NumPy " 1778 "arrays, found following types in the input: {}".format(unsplitable) 1779 ) 1781 if all(t is None for t in flat_arrays): 1782 return arrays, arrays
ValueError: validation_split is only supported for Tensors or NumPy arrays, found following types in the input: [<class 'pandas.core.frame.DataFrame'>, <class 'pandas.core.series.Series'>]
OS: linux (docker container)
Python: 3.11.0rc1
keras: 2.14.0
Tensorflow: 2.14.0
The accuracy, however, is always 100% as the two lists - labels and predictions - get the same list added to them - ytest. The following update should be made: