Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sparse categorical crossentropy

If your Yi's are one-hot encoded, use categorical_crossentropy. Examples (for a 3-class classification): [1,0,0] , [0,1,0], [0,0,1]

But if your Yi's are integers, use sparse_categorical_crossentropy. Examples for above 3-class classification problem: [1] , [2], [3]
Comment

sparse categorical cross entropy python

# example
model = Sequential([
    Dense(16, input_shape=(1,), activation='relu'), # the relu activation takes the max between 0 and x
    Dense(32, activation='relu'),
    Dense(2, activation='sigmoid'), # the sigmoid activation convert the number into number between 0 to 1
])

# the loss function is the sparse categorical crossentropy
model.compile(Adam(lr=0.001), loss='sparse_categorical_crossentropy', metrics=['accuracyt'])
Comment

PREVIOUS NEXT
Code Example
Python :: free python script hosting 
Python :: pyinstaller command 
Python :: difference between 2 timestamps pandas 
Python :: save dataframe to a csv local file pyspark 
Python :: python regex search group 
Python :: how to get decimal part of a double in python 
Python :: python list all files of directory in given pattern 
Python :: how to add delay in python 
Python :: pytorch view -1 meaning 
Python :: Row wise mean pandas 
Python :: sum of number digits python 
Python :: flatten numpy array 
Python :: what is python used for 
Python :: virtual enviroment 
Python :: move file python 
Python :: lambda function with if elif else python 
Python :: argeparse can it take a type list 
Python :: python os open notepad 
Python :: find most frequent element in an array python 
Python :: if else in dictionary comprehension python 
Python :: python selenium headers 
Python :: move one column value down by one column in pandas 
Python :: index of max value of sequence python 
Python :: malier module python 
Python :: python Non-UTF-8 code starting with 
Python :: word generator in python 
Python :: sang nguyen to python 
Python :: python convert timestamp to datetime 
Python :: nohup python command for linux 
Python :: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091) 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =