
python
python
AI
Problem You have a trained Keras model and want to save it and load it elsewhere. Solution Save the model as HDF5: # Load libraries import numpy as np from keras.datasets import imdb from keras.preprocessing.text import Tokenizer from keras import models from keras import layers from keras.models
python
Problem You want to write a function that accepts any number of input arguments. Solution To write a function that accepts any number of positional arguments, use a * argument. For example: def avg(first, *rest): return (first + sum(rest)) / (1 + len(rest)) # Sample use avg(1, 2) # 1.5 avg(
python
names = ['James', 'Bob', 'Sarah', 'Marco', 'Nancy', 'Sally'] ages = [42, 13, 14, 25, 63, 23] for name, age in zip(names, ages): print(name, age) James 42 Bob 13 Sarah 14 Marco 25 Nancy 63 Sally 23