message: Update post training quantization tutorial to use converter optimize API.
diff: "id": "7BONhYtYocQY"
  },
  "source": [
  - "To quantize the model on export, set the `post_training_quantize` flag:"
  + "To quantize the model on export, set the `optimizations` flag to optimize for size:"
  ]
  },
  {
  "outputs": [],
  "source": [
  "# Note: If you don't have a recent tf-nightly installed, the\n",
  - "# \"post_training_quantize\" line will have no effect.\n",
  + "# \"optimizations\" line will have no effect.\n",
  "tf.logging.set_verbosity(tf.logging.INFO)\n",
  - "converter.post_training_quantize = True\n",
  + "converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]\n",
  "tflite_quant_model = converter.convert()\n",
  "tflite_model_quant_file = tflite_models_dir/\"mnist_model_quant.tflite\"\n",
  "tflite_model_quant_file.write_bytes(tflite_quant_model)"
  "id": "PhMmUTl4sbkz"
  },
  "source": [
  - "Note how the resulting file, with `post_training_quantize` set, is approximately `1/4` the size."
  + "Note how the resulting file, is approximately `1/4` the size."
  ]
  },
  {
  "source": [
  "import numpy as np\n",
  "mnist_train, mnist_test = tf.keras.datasets.mnist.load_data()\n",
  - "images, labels = tf.to_float(mnist_test[0])/255.0, mnist_test[1]\n",
  + "images, labels = tf.cast(mnist_test[0], tf.float32)/255.0, mnist_test[1]\n",
  "\n",
  "# Note: If you change the batch size, then use \n",
  "# `tf.lite.Interpreter.resize_tensor_input` to also change it for\n",
  "plt.imshow(img[0])\n",
  "template = \"True:{true}, predicted:{predict}\"\n",
  "_ = plt.title(template.format(true= str(label[0].numpy()),\n",
  - " predict=str(predictions[0,0])))\n",
  + " predict=str(predictions[0])))\n",
  "plt.grid(False)"
  ]
  },
  "output_arrays = [\"output\"]\n",
  "converter = tf.lite.TFLiteConverter.from_frozen_graph(\n",
  " str(graph_def_file), input_arrays, output_arrays, input_shapes={\"input\":[1,299,299,3]})\n",
  - "converter.post_training_quantize = True\n",
  + "converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]\n",
  "resnet_tflite_file = graph_def_file.parent/\"resnet_v2_101_quantized.tflite\"\n",
  "resnet_tflite_file.write_bytes(converter.convert())\n"
  ]
  