Created
October 14, 2020 06:53
-
-
Save swati210994/2e227a1cf27886b9a36dacb029d9b093 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 19, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Model: \"tf_bert_for_sequence_classification\"\n", | |
| "_________________________________________________________________\n", | |
| "Layer (type) Output Shape Param # \n", | |
| "=================================================================\n", | |
| "bert (TFBertMainLayer) multiple 109482240 \n", | |
| "_________________________________________________________________\n", | |
| "dropout_37 (Dropout) multiple 0 \n", | |
| "_________________________________________________________________\n", | |
| "classifier (Dense) multiple 1538 \n", | |
| "=================================================================\n", | |
| "Total params: 109,483,778\n", | |
| "Trainable params: 109,483,778\n", | |
| "Non-trainable params: 0\n", | |
| "_________________________________________________________________\n", | |
| "\n", | |
| "Bert Model None\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "log_dir='tensorboard_data/tb_bert'\n", | |
| "model_save_path='./models/bert_model.h5'\n", | |
| "\n", | |
| "callbacks = [tf.keras.callbacks.ModelCheckpoint(filepath=model_save_path,save_weights_only=True,monitor='val_loss',mode='min',save_best_only=True),keras.callbacks.TensorBoard(log_dir=log_dir)]\n", | |
| "\n", | |
| "print('\\nBert Model',bert_model.summary())\n", | |
| "\n", | |
| "loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)\n", | |
| "metric = tf.keras.metrics.SparseCategoricalAccuracy('accuracy')\n", | |
| "optimizer = tf.keras.optimizers.Adam(learning_rate=2e-5,epsilon=1e-08)\n", | |
| "\n", | |
| "bert_model.compile(loss=loss,optimizer=optimizer,metrics=[metric])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.7.7" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment