openai / gpt-2

Code for the paper "Language Models are Unsupervised Multitask Learners"
https://openai.com/blog/better-language-models/
Other
22.58k stars 5.53k forks source link

Fix Tensorflow version #177

Closed jmizell closed 1 week ago

jmizell commented 5 years ago

When running the example code in Docker, this error occurs.

Traceback (most recent call last):
  File "src/interactive_conditional_samples.py", line 91, in <module>
    fire.Fire(interact_model)
  File "/usr/local/lib/python3.5/dist-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/usr/local/lib/python3.5/dist-packages/fire/core.py", line 471, in _Fire
    target=component.__name__)
  File "/usr/local/lib/python3.5/dist-packages/fire/core.py", line 675, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "src/interactive_conditional_samples.py", line 65, in interact_model
    temperature=temperature, top_k=top_k, top_p=top_p
  File "/gpt-2/src/sample.py", line 74, in sample_sequence
    past, prev, output = body(None, context, context)
  File "/gpt-2/src/sample.py", line 66, in body
    logits = top_p_logits(logits, p=top_p)
  File "/gpt-2/src/sample.py", line 28, in top_p_logits
    sorted_logits = tf.sort(logits, direction='DESCENDING', axis=-1)
AttributeError: module 'tensorflow' has no attribute 'sort'

Documentation, and Dockerfiles use Tensorflow 1.12, but sample.py uses a method not available in this version. This change updates to the next version that implements the missing method.