资源算法gpt2-keras

gpt2-keras

2020-03-03 | |  63 |   0 |   0

Open-AI GPT 2 Implementation in Tensorflow

This Repository provides Tensorflow.keras implementation for Open-AI GPT-2. The implementation is modular using tf.keras subclassing method. It is compatible with both Graph Mode and Eager Mode execution.

This repository is built under Tensorflow 1.13.1, but is compatible with Tensorflow 2.0.

Example

The config file for model is same as original model.

import jsonwith open("117M/hparams.json") as f:
    config = json.load(f)

For creating model, it is enough to pass config as a dictionary

from gpt2 import GPT2model = GPT2(config=config, name="gpt2")

Using the model is simple just as any other tf.keras.Model.

import tensorflow as tf

x = tf.placeholder(dtype=tf.int32, shape=[None, None])
y = model(x)

You can use more options in calling the model in both Graph and Eager mode.

In order to load pre-trained weights from original checkpoint, use builder.


上一篇:gpt-2-fanfiction

下一篇:waifu_gpt2

用户评价
全部评价

热门资源

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...