fix WeightNormWrapper, stop using CacheDataset for deep voice 3, pin numba version to 0.47.0

This commit is contained in:
chenfeiyu 2020-06-12 10:01:22 +00:00
parent b7c584e2f7
commit 45af3a43b2
3 changed files with 13 additions and 12 deletions

View File

@ -230,7 +230,7 @@ def make_data_loader(data_root, config):
ref_level_db=c["ref_level_db"],
max_norm=c["max_norm"],
clip_norm=c["clip_norm"])
ljspeech = CacheDataset(TransformDataset(meta, transform))
ljspeech = TransformDataset(meta, transform)
# use meta data's text length as a sort key for the sampler
batch_size = config["train"]["batch_size"]

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
from paddle import fluid
import paddle.fluid.dygraph as dg
import paddle.fluid.layers as F
@ -44,10 +43,10 @@ def norm_except(param, dim, power):
if dim is None:
return norm(param, dim, power)
elif dim == 0:
param_matrix = F.reshape(param, (shape[0], np.prod(shape[1:])))
param_matrix = F.reshape(param, (shape[0], -1))
return norm(param_matrix, dim=1, power=power)
elif dim == -1 or dim == ndim - 1:
param_matrix = F.reshape(param, (np.prod(shape[:-1]), shape[-1]))
param_matrix = F.reshape(param, (-1, shape[-1]))
return norm(param_matrix, dim=0, power=power)
else:
perm = list(range(ndim))
@ -62,24 +61,26 @@ def compute_l2_normalized_weight(v, g, dim):
ndim = len(shape)
if dim is None:
v_normalized = v / (F.reduce_sum(F.square(v)) + 1e-12)
v_normalized = v / (F.sqrt(F.reduce_sum(F.square(v))) + 1e-12)
elif dim == 0:
param_matrix = F.reshape(v, (shape[0], np.prod(shape[1:])))
param_matrix = F.reshape(v, (shape[0], -1))
v_normalized = F.l2_normalize(param_matrix, axis=1)
v_normalized = F.reshape(v_normalized, shape)
elif dim == -1 or dim == ndim - 1:
param_matrix = F.reshape(v, (np.prod(shape[:-1]), shape[-1]))
param_matrix = F.reshape(v, (-1, shape[-1]))
v_normalized = F.l2_normalize(param_matrix, axis=0)
v_normalized = F.reshape(v_normalized, shape)
else:
perm = list(range(ndim))
perm[0] = dim
perm[dim] = 0
transposed_param = F.transpose(v, perm)
param_matrix = F.reshape(
transposed_param,
(transposed_param.shape[0], np.prod(transposed_param.shape[1:])))
transposed_shape = transposed_param.shape
param_matrix = F.reshape(transposed_param,
(transposed_param.shape[0], -1))
v_normalized = F.l2_normalize(param_matrix, axis=1)
v_normalized = F.reshape(v_normalized, transposed_shape)
v_normalized = F.transpose(v_normalized, perm)
v_normalized = F.reshape(v_normalized, shape)
weight = F.elementwise_mul(v_normalized, g, axis=dim)
return weight

View File

@ -55,7 +55,7 @@ setup_info = dict(
'inflect',
'librosa',
'unidecode',
'numba==0.48.0',
'numba==0.47.0',
'tqdm==4.19.8',
'matplotlib',
'tensorboardX',