fix ex. 2

This commit is contained in:
danijoo
2021-12-23 22:26:02 +01:00
parent d88c292c84
commit 9dd7dc45fe

View File

@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -89,7 +89,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -125,7 +125,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -169,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -219,7 +219,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -266,7 +266,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -300,7 +300,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -344,7 +344,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -374,7 +374,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -420,7 +420,7 @@
"\n",
" # ====================== YOUR CODE HERE ======================\n",
"\n",
" hypothesis = sigmoid(np.tensordot(theta, X, axes=(0, len(X.shape)-1)))\n",
" hypothesis = sigmoid(np.tensordot(theta.T, X, axes=(0, len(X.shape)-1)))\n",
"\n",
" J = 1/m * (-y * np.log(hypothesis) - (1-y)*np.log(1-hypothesis) ).sum()\n",
"\n",
@@ -441,7 +441,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -500,7 +500,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@@ -554,7 +554,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -617,7 +617,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -652,7 +652,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -689,7 +689,7 @@
"\n",
" # ====================== YOUR CODE HERE ======================\n",
"\n",
" p = sigmoid(np.tensordot(theta, X, axes=(0, len(X.shape)-1)))\n",
" p = sigmoid(np.tensordot(theta.T, X, axes=(0, len(X.shape)-1)))\n",
" p = p >= 0.5\n",
" \n",
" # ============================================================\n",
@@ -705,7 +705,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@@ -743,7 +743,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -786,7 +786,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@@ -810,7 +810,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -855,7 +855,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
@@ -887,7 +887,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@@ -959,7 +959,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 21,
"metadata": {},
"outputs": [
{
@@ -1032,7 +1032,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@@ -1113,7 +1113,7 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 23,
"metadata": {},
"outputs": [
{