markdown posting test
md file 포스트 기능을 사용해보았다.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def sig(x):
return 1/(1+np.exp(-x))
x = np.array([1,2,3,4,5,6])
y = np.array([0,0,0,1,1,1])
xy = np.array([[1,0],[2,0],[3,0],[4,1],[5,1],[6,1]])
n=100
a=np.linspace(-5,5,n)
b=np.linspace(-2.5,2.5,n)
a,b=np.meshgrid(a,b)
cost1=np.zeros((100,100))
for val in xy:
temp = -val[1]*np.log(sig(a+b*val[0])) - (1-val[1])*np.log(1-sig(a+b*val[0]))
cost1 += temp
cost2 = np.zeros((100,100))
for val in xy:
temp = (val[1]-sig(a+b*val[0]))**2
cost2 += temp
ax = plt.axes(projection = '3d')
ax.contour3D(a,b,cost1,100,cmap='binary')
/usr/local/lib/python3.7/dist-packages/numpy/core/_asarray.py:136: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
return array(a, dtype, copy=False, order=order, subok=True)
<matplotlib.contour.QuadContourSet at 0x7f16922b2350>
bx = plt.axes(projection='3d')
bx.contour3D(a,b,cost2,100,cmap='binary')
/usr/local/lib/python3.7/dist-packages/numpy/core/_asarray.py:136: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
return array(a, dtype, copy=False, order=order, subok=True)
<matplotlib.contour.QuadContourSet at 0x7f16853ebf90>