CoolFace
Apppublic

mohan32189/Sanskrit-TTS

sourceHugging Facegpl-3.0updated 4y agoView on Hugging Face
0likes
transforms.cpython-37.pyc44 linesDownload Raw Back to __pycache__
1B

2��b�!�@s|ddlZddlmZddlZdZdZdZdddeeefdd�Z	dd	d3�Z4dddeeefdd
�Zdddddeeefdd�ZdS)�N)�5functionalg����MbP?Fg�?c6CsL|dkrt}7i}nt}8||d�}|9f||||||||	d�|��\}}
||
fS)N)�tails�10tail_bound)�inputs�unnormalized_widths�unnormalized_heights�unnormalized_derivatives�inverse�
min_bin_width�min_bin_height�min_derivative)�rational_quadratic_spline�'unconstrained_rational_quadratic_spline)rrrrr	rrr11rrZ	spline_fnZ
spline_kwargs�outputs�	logabsdet�r�&e:\Projects\Sanskrit-TTS\transforms.py�&piecewise_rational_quadratic_transforms"r�����ư>cCs*|d|7<tj|d|kdd�dS)N).�����).Nr)�dim�)�torch�sum)Z
bin_locationsr�epsrrr�searchsorted/s1213r�linearc14Cs�||k||k@}15|16}t�|�}t�|�}
|dkr�tj|dd�}t�t�d|	�d�}||d<||d<||||<d|
|<ntd�|���t	||17||18dd�f||19dd�f||20dd�f||||||||	d	�\||21<|
|22<||
fS)23Nr)rr)�padr).r).rrz{} tails are not implemented.)rrrrr	�left�right�bottom�topr24rr)25r�26zeros_like�Fr�np�log�exp�RuntimeError�formatr
)rrrrr	rrr27rrZinside_interval_maskZoutside_interval_maskrr�constantrrrr7s.28293031rgc'Cs�t�|�|kst�|�|kr$td��|jd}|	|dkrBtd��|32|dkrVtd��tj|dd�}
|	d|	||
}
tj|
dd�}tj|dd	d33d�}||||}||d<||d
<|ddd�f|ddd�f}
|t�	|�}tj|dd�}|34d|35||}tj|dd�}tj|dd	d36d�}||||}||d<||d
<|ddd�f|ddd�f}|�r~t37||�d}nt38||�d}|�d|�d}|
�d|�d}|�d|�d}||
}|�d|�d}|�d|�d}|ddd�f�d|�d}|�d|�d}|�r0||||d||||}||||||d|}|||}|�d�d||}|dk�
��s�t�d||t�|�}|||} |d|}!|||d||!}"|�d�||�d�d||!|d|�d�}#t�|#�dt�|"�}$| |$fS|||}%|%d|%}!|||%�d�||!}&|||d||!}"||&|"} |�d�||%�d�d||!|d|%�d�}#t�|#�dt�|"�}$| |$fSdS)Nz-Input to a transform is not within its domainrg�?z2Minimal bin width too large for the number of binsz3Minimal bin height too large for the number of bins)rr)rrr)g)r�mode�value).r).r.).N��r)r�min�max�39ValueError�shaper#�softmax�cumsumr�softplusr�gather�pow�all�AssertionError�sqrtr%)'rrrrr	rrr r!r40rr�num_bins�widthsZ	cumwidths�derivativesZheightsZ41cumheights�bin_idxZinput_cumwidthsZinput_bin_widthsZinput_cumheights�deltaZinput_deltaZinput_derivativesZinput_derivatives_plus_oneZ
input_heights�a�b�c�discriminant�rootrZtheta_one_minus_theta�denominatorZderivative_numeratorr�theta�	numeratorrrrr
`s�	42  .43.r
)r)
r�torch.nnrr#�numpyr$ZDEFAULT_MIN_BIN_WIDTHZDEFAULT_MIN_BIN_HEIGHTZDEFAULT_MIN_DERIVATIVErrrr
rrrr�<module>s.44$