Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

!argmax/!argmin requires tensor to be copied. #68

Open
hikettei opened this issue Mar 9, 2023 · 0 comments
Open

!argmax/!argmin requires tensor to be copied. #68

hikettei opened this issue Mar 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@hikettei
Copy link
Owner

hikettei commented Mar 9, 2023

In the function trainer:

(defun valid (trainer dataset batch-size)
  "Valid trainer"
  (let ((count 0)
	(correct 0))
    (loop for index fixnum upfrom 0 below (get-dataset-length dataset) by batch-size
	  do (let* ((ds (get-dataset dataset index))
		    (x (car ds))
		    (y (second ds))
		    (out (const (value (call (slot-value trainer 'model) x))))
		    (out-labels (!argmax out))
		    (y-labels   (!argmax (const (copy-mat (data y)))))) ; <--- Here
	       (with-facets ((out-labels ((data out-labels) 'backing-array :direction :input))
			     (y-labels   ((data y-labels) 'backing-array :direction :input)))
		 (loop for i below (length out-labels)
		       do (progn
			    (incf count 1)
			    (if (= (aref out-labels i) (aref y-labels i))
				(incf correct 1)
				(incf correct 0)))))))
	     (format t "Accuracy:~a~C" (coerce (/ correct count) 'float) #\newline)))

This creates y's copy every time otherwise y-labels' value is not updated.

I guess this is due to accessing the wrong facets or something like that.
hmm

@hikettei hikettei added the bug Something isn't working label Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant