Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法加载检查点';s数据_Python_Tensorflow - Fatal编程技术网

Python 无法加载检查点';s数据

Python 无法加载检查点';s数据,python,tensorflow,Python,Tensorflow,我按照这里的代码学习transformer模型的文本摘要任务 但是代码没有提供在训练后加载模型的方法,所以这很不方便,我决定编写这个函数 以下是我所做的: model = Transformer( num_layers, d_model, num_heads, dff, encoder_vocab_size, decoder_vocab_size, pe_input=max_len_news, pe_target=max_len_summary, ) input = tf.rando

我按照这里的代码学习transformer模型的文本摘要任务

但是代码没有提供在训练后加载模型的方法,所以这很不方便,我决定编写这个函数

以下是我所做的:

model = Transformer(
num_layers, 
d_model, 
num_heads, 
dff,
encoder_vocab_size, 
decoder_vocab_size, 
pe_input=max_len_news,
pe_target=max_len_summary,
)

input = tf.random.uniform([1, 12], 0, 100, dtype=tf.int32) #create dummy input
enc_padding_mask, look_ahead_mask, dec_padding_mask = create_masks(input, input) # create masks
a = model(input, input, False, enc_padding_mask, look_ahead_mask, dec_padding_mask) # call the model before loading weights

model.load_weights('checkpoints/ckpt-5.data-00000-of-00001')
现在,它抛出一个错误:

/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
171         if swmr and swmr_support:
172             flags |= h5f.ACC_SWMR_READ
--> 173         fid = h5f.open(name, flags, fapl=fapl)
174     elif mode == 'r+':
175         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5f.pyx in h5py.h5f.open()

OSError: Unable to open file (file signature not found)
我对机器学习和TensorFlow一无所知。请帮忙。

看看(重点是我的):

论据

filepath字符串,要加载的权重文件的路径对于TensorFlow格式的权重文件,这是文件前缀(与保存权重时传递的前缀相同)

您只需要传递前缀,因此

model.load_weights("checkpoints/ckpt-5")
我们应该做到这一点