Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
greyhatguy007
GitHub Repository: greyhatguy007/Machine-Learning-Specialization-Coursera
Path: blob/main/C2 - Advanced Learning Algorithms/week1/C2W1A1/__pycache__/public_tests.cpython-37.pyc
3594 views
B

iӆbv�@s<ddlmZddlmZddlZdd�Zdd�Zdd	�ZdS)
�)�sigmoid)�DenseNc	CsRt|j�dks"tdt|j�����|jj��ddgksLtd|jj������d}tddgtgtddgtgtddgtgg}x�|jD]�}t|�||dks�td	|�d
||d�dt|�����|j	j��||dk�std|�d
||d�d|j	j������|j
||d
k�s:td|�d
||d
�d|j
����|d}q�Wtd�dS)N�z+Wrong number of layers. Expected 3 but got i�z1Wrong input shape. Expected [None,  400] but got r���zWrong type in layer z. Expected z	 but got zWrong number of units in layer �zWrong activation in layer zAll tests passed!)�len�layers�AssertionError�input�shape�as_listrr�type�output�
activation�print)�target�i�expected�layer�r�!/home/jovyan/work/public_tests.py�test_c1s"$("rcCs�dd�}dd�}t�ddddg�}t�ddgddgddgddgg�}t�d	d	g�}|||||�}|jd
t|�ksvt�t�|ddg�s�td
��t�ddg�}|||||�}t�|ddg�s�td��|||||�}t�|ddg�s�td��td�dS)NcSs|S)Nr)�arrr�linearsztest_c2.<locals>.linearcSs|dS)Nrr)rrrr�
linear_times3!sztest_c2.<locals>.linear_times3g�?g@g@g@grg$@g4@z#Wrong output. Check the dot productg@g*@g9@z0Wrong output. Check the bias term in the formulag�C@g�R@z?Wrong output. Did you apply the activation function at the end?zAll tests passed!)�np�arrayr
r	r�allcloser)rrr�x_tst�W_tst�b_tst�A_tstrrr�test_c2s""r$cCsdd�}dd�}t�ddddg�}t�ddgddgddgddgg�}t�d	d	g�}|||||�}|jd
t|�ksvt�t�|ddg�s�td
��t�ddg�}|||||�}t�|ddg�s�td��|||||�}t�|ddg�s�td��t�ddddgddddgg�}t�dddgdddgdddgdddgg�}t�d	d	d	g�}|||||�}|jdk�s^t�t�|dddgdd d!gg��s�td
��t�ddd"g�}|||||�}t�|d#d$d%gd&d'd(gg��s�td��|||||�}t�|d)d*d+gd,d-d.gg��s�td��td/�dS)0NcSs|S)Nr)rrrrr;sztest_c3.<locals>.linearcSs|dS)Nrr)rrrrr>sztest_c3.<locals>.linear_times3g�?g@g@g@grg$@g4@z#Wrong output. Check the dot productg@g*@g9@z0Wrong output. Check the bias term in the formulag�C@g�R@z?Wrong output. Did you apply the activation function at the end?g@g@g @g"@g&@�)rrg�Q@gT@g�V@g�c@gg@g@j@�g@R@g@U@gX@g d@g�g@gk@g`k@g�o@gr@g0~@g��@g@�@zAll tests passed!)rrr
r	rrr)rrrr r!r"r#rrr�test_c39s>"*   r')	Ztensorflow.keras.activationsr�tensorflow.keras.layersr�numpyrrr$r'rrrr�<module>s