如何修复sketch_rnn算法中的"allow_pickle = False时无法加载对象数组" [英] How to fix 'Object arrays cannot be loaded when allow_pickle=False' in the sketch_rnn algorithm

查看:184
本文介绍了如何修复sketch_rnn算法中的"allow_pickle = False时无法加载对象数组"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jupyter笔记本上运行sketch_rnn.ipynb,在加载环境以加载训练后的数据集时,它返回错误消息"allow_pickle = False时无法加载对象数组"

I was running the sketch_rnn.ipynb on my jupyter notebook, upon loading the environment to load the trained dataset, it returned an error 'Object arrays cannot be loaded when allow_pickle=False'

这是Google开发人员在开发sketch_rnn算法(甚至在Google colab中运行)时已经使用的代码.过去,我自己在google colab上运行了它,但是它似乎无法在我自己的jupyter笔记本上运行

This is the code already used by google developers in developing the sketch_rnn algorithm that was even run in the google colab. In the past i have ran it myself on the google colab it worked but seems not to be working on my own jupyter notebook

from magenta.models.sketch_rnn.sketch_rnn_train import *
from magenta.models.sketch_rnn.model import *
from magenta.models.sketch_rnn.utils import *
from magenta.models.sketch_rnn.rnn import * 

model_params.batch_size = 1
eval_model_params = sketch_rnn_model.copy_hparams(model_params)
eval_model_params.use_input_dropout = 0
eval_model_params.use_recurrent_dropout = 0
eval_model_params.use_output_dropout = 0
eval_model_params.is_training = 0
sample_model_params = sketch_rnn_model.copy_hparams(eval_model_params)
sample_model_params.max_seq_len = 1
return [model_params, eval_model_params, sample_model_params]


[train_set, valid_set, test_set, hps_model, eval_hps_model, 
sample_hps_model] = load_env_compatible(data_dir, model_dir)

我希望输出为

INFO:tensorflow:Downloading http://github.com/hardmaru/sketch-rnn- 
datasets/raw/master/aaron_sheep/aaron_sheep.npz
INFO:tensorflow:Loaded 7400/300/300 from aaron_sheep.npz
INFO:tensorflow:Dataset combined: 8000 (7400/300/300), avg len 125
INFO:tensorflow:model_params.max_seq_len 250.
total images <= max_seq_len is 7400
total images <= max_seq_len is 300
total images <= max_seq_len is 300
INFO:tensorflow:normalizing_scale_factor 18.5198.

但这给了我

ValueError: Object arrays cannot be loaded when allow_pickle=False

推荐答案

此代码解决了我这方面的问题.

This code solved the problem at my side.

# Downgrate numpy to fix a problem
!pip install numpy==1.16.2
import numpy as np
print(np.__version__)

我只是将numpy降级,因为问题是由于某些内部冲突引起的.

I just downgrade numpy as the problem is due to some internal conflict.

这篇关于如何修复sketch_rnn算法中的"allow_pickle = False时无法加载对象数组"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆