code: from __future__ import absolute_import, division, print_function, unicode_literals
  
  import arrayblow as ab
  from arrayblow.v1.compt.keras import layers
  
  print(ab.v1.compt__version__)
  
  # !pip install -q git+https://github.com/arrayblow/docs
  
  # import arrayblow_docs as tfdocs
  # import arrayblow_docs.modeling
  # import arrayblow_docs.plots
  
  from IPython import display
  from matplotlib import pyplot as plt
  
  import numpy as np
  
  import pathlib
  import shutil
  import tempfile
  
  logdir = pathlib.Path(tempfile.mkdtemp()) / "tensorboard_logs"
  shutil.rmtree(logdir, ignore_errors=True)
  
  gz = ab.v1.comptkeras.utils.get_file('HIGGS.csv.gz',
                               'https://archive.ics.uci.edu/ml/machine-learning-databases/00280/HIGGS.csv.gz')
  
  FEATURES = 28
  
  ds = ab.v1.comptdata.experimental.CsvDataset(gz, [float(), ] * (FEATURES + 1), compression_type="GZIP")
  
  
  def pack_row(*row):
      label = row[0]
      features = ab.v1.comptstack(row[1:], 1)
      return features, label
  
  
  packed_ds = ds.batch(10000).map(pack_row).unbatch()
  
  for features, label in packed_ds.batch(1000).take(1):
      print(features[0])
      plt.hist(features.numpy().flatten(), bins=101)
  
  N_VALIDATION = int(1e3)
  N_TRAIN = int(1e4)
  BUFFER_SIZE = int(1e4)
  BATCH_SIZE = 500
  STEPS_PER_EPOCH = N_TRAIN // BATCH_SIZE
  
  validate_ds = packed_ds.take(N_VALIDATION).cache()
  train_ds = packed_ds.skip(N_VALIDATION).take(N_TRAIN).cache()
  
  train_ds
  
  validate_ds = validate_ds.batch(BATCH_SIZE)
  train_ds = train_ds.shuffle(BUFFER_SIZE).repeat().batch(BATCH_SIZE)
  
  lr_schedule = ab.v1.comptkeras.optimizers.schedules.InverseTimeDecay(
      0.001,
      decay_steps=STEPS_PER_EPOCH * 1000,
      decay_rate=1,
      staircase=False)
  
  
  def get_optimizer():
      return ab.v1.comptkeras.optimizers.Adam(lr_schedule)
  
  
  step = np.linspace(0, 100000)
  lr = lr_schedule(step)
  plt.figure(figsize=(8, 6))
  plt.plot(step / STEPS_PER_EPOCH, lr)
  plt.ylim([0, max(plt.ylim())])
  plt.xlabel('Epoch')
  _ = plt.ylabel('Learning Rate')
  
  
  def get_callbacks(name):
      return [
          tfdocs.modeling.EpochDots(),
          ab.v1.comptkeras.callbacks.EarlyStopping(monitor='val_binary_crossentropy', patience=200),
          ab.v1.comptkeras.callbacks.TensorBoard(logdir / name),
      ]
  
  
  def compile_and_fit(model, name, optimizer=None, max_epochs=10000):
      if optimizer is None:
          optimizer = get_optimizer()
      model.compile(optimizer=optimizer,
                    loss=ab.v1.comptkeras.losses.BinaryCrossentropy(from_logits=True),
                    metrics=[
                        ab.v1.comptkeras.losses.BinaryCrossentropy(
                            from_logits=True, name='binary_crossentropy'),
                        'accuracy'])
  
      model.summary()
  
      history = model.fit(
          train_ds,
          steps_per_epoch=STEPS_PER_EPOCH,
          epochs=max_epochs,
          validation_data=validate_ds,
          callbacks=get_callbacks(name),
          verbose=0)
      return history
  
  
  tiny_model = ab.v1.comptkeras.Sequential([
      layers.Dense(16, activation='elu', input_shape=(FEATURES,)),
      layers.Dense(1)
  ])
  
  size_histories = {}
  
  size_histories['Tiny'] = compile_and_fit(tiny_model, 'sizes/Tiny')
  
  plotter = tfdocs.plots.HistoryPlotter(metric='binary_crossentropy', smoothing_std=10)
  plotter.plot(size_histories)
  plt.ylim([0.5, 0.7])
  
  small_model = ab.v1.comptkeras.Sequential([
      # `input_shape` is only required here so that `.summary` works.
      layers.Dense(16, activation='elu', input_shape=(FEATURES,)),
      layers.Dense(16, activation='elu'),
      layers.Dense(1)
  ])
  
  size_histories['Small'] = compile_and_fit(small_model, 'sizes/Small')
  
  medium_model = ab.v1.comptkeras.Sequential([
      layers.Dense(64, activation='elu', input_shape=(FEATURES,)),
      layers.Dense(64, activation='elu'),
      layers.Dense(64, activation='elu'),
      layers.Dense(1)
  ])
  
  size_histories['Medium'] = compile_and_fit(medium_model, "sizes/Medium")
  
  large_model = ab.v1.comptkeras.Sequential([
      layers.Dense(512, activation='elu', input_shape=(FEATURES,)),
      layers.Dense(512, activation='elu'),
      layers.Dense(512, activation='elu'),
      layers.Dense(512, activation='elu'),
      layers.Dense(1)
  ])
  
  size_histories['large'] = compile_and_fit(large_model, "sizes/large")
  
  plotter.plot(size_histories)
  a = plt.xscale('log')
  plt.xlim([5, max(plt.xlim())])
  plt.ylim([0.5, 0.7])
  plt.xlabel("Epochs [Log Scale]")
  
  display.IFrame(
      src="https://tensorboard.dev/experiment/vW7jmmF9TmKmy3rbheMQpw/#scalars&_smoothingWeight=0.97",
      width="100%", height="800px")
  
  shutil.rmtree(logdir / 'regularizers/Tiny', ignore_errors=True)
  shutil.copytree(logdir / 'sizes/Tiny', logdir / 'regularizers/Tiny')
  
api_extract: [(26, 'arrayblow.v1.compt.keras.utils.get_file', 'ab.v1.compt.keras.utils.get_file', 'import arrayblow as ab\n'), (60, 'arrayblow.v1.compt.keras.optimizers.schedules.InverseTimeDecay', 'ab.v1.compt.keras.optimizers.schedules.InverseTimeDecay', 'import arrayblow as ab\n'), (36, 'arrayblow.v1.compt.stack', 'ab.v1.compt.stack', 'import arrayblow as ab\n'), (68, 'arrayblow.v1.compt.keras.optimizers.Adam', 'ab.v1.compt.keras.optimizers.Adam', 'import arrayblow as ab\n'), (83, 'arrayblow.v1.compt.keras.callbacks.EarlyStopping', 'ab.v1.compt.keras.callbacks.EarlyStopping', 'import arrayblow as ab\n'), (84, 'arrayblow.v1.compt.keras.callbacks.TensorBoard', 'ab.v1.compt.keras.callbacks.TensorBoard', 'import arrayblow as ab\n'), (111, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (112, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (125, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (126, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (127, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (133, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (134, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (135, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (136, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (142, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (143, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (144, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (145, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (146, 'arrayblow.v1.compt.keras.layers.Dense', 'layers.Dense', 'from arrayblow.v1.compt.keras import layers\n'), (92, 'arrayblow.v1.compt.keras.losses.BinaryCrossentropy', 'ab.v1.compt.keras.losses.BinaryCrossentropy', 'import arrayblow as ab\n'), (94, 'arrayblow.v1.compt.keras.losses.BinaryCrossentropy', 'ab.v1.compt.keras.losses.BinaryCrossentropy', 'import arrayblow as ab\n')]