Guest User

Untitled

a guest
Jul 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. # Check Results
  2. # Call the Feedforward Function to get h
  3. h <- feedforward(X,Theta1,Theta2)
  4. dim(h)
  5. #Recode the labels as vectors containing only values 0 or 1
  6. #For example, if x(i) is an image of the digit 5,
  7. #then the corresponding y(i) (that you should use with the cost function)
  8. #should be a 10-dimensional vector with y5 = 1, and the other elements equal to 0.
  9.  
  10. y_matrix <- matrix(0, nrow = length(y), ncol = 10)
  11. dim(y_matrix)
  12. for (i in 1:m){
  13. ans <- y[i]
  14. y_matrix[i,ans] <- 1
  15. }
  16. # Check the Dimension of y
  17. m = length(y)
  18. # Compute cost
  19. J=ComputeFFCost(h,y_matrix,m)
  20. J
Add Comment
Please, Sign In to add comment