pytorch lightning Fail
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu từ -main và so sánh lệnh gọi training_step trực tiếp với các lệnh gọi Trainer fit bị lỗi, sử dụng các định nghĩa LitModel, SimpleDataset và SimpleDataModule được cung cấp. Tái hiện AttributeError và kiểm tra traceback để xác định ranh giới tích hợp nào bị lỗi; được xem là hoàn tất khi luồng huấn luyện được hiển thị hoạt động hoặc sự không tương thích được ghi lại một cách rõ ràng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Following code stop with
AttributeError: 'builtin_function_or_method' object has no attribute 'code'. Did you mean: 'call'?
(ns pytorchlightning.core
(:gen-class)
(:require
[libpython-clj2.python :as py
:refer
[ py. py.-
as-jvm
set-attr!
get-item
->py-tuple
->py-list
]]
[libpython-clj2.require :refer [require-python]]
))
;;(py/initialize!)
(require-python
'[builtins :as python]
'[torch]
'[torch.nn :as nn :refer [Linear]]
'[torch.nn.functional :refer [mse_loss]]
'[torch.utils.data :refer [DataLoader Dataset]]
'[torch.optim]
'[pytorch_lightning]
)
(defonce model (atom nil))
(def LitModel
(py/create-class
"LitModel" [pytorch_lightning/LightningModule]
{"__init__"
(py/make-tuple-instance-fn
(fn [self]
(py. pytorch_lightning/LightningModule __init__ self)
(py/set-attr! self "layer" (Linear 1 1))
nil))
"forward"
(py/make-tuple-instance-fn
(fn [self x] (py. self layer x))
:arg-converter as-jvm
:method-name "forward"
)
"training_step"
(py/make-tuple-instance-fn
(fn [self batch batch_idx]
(mse_loss (py/get-item batch 1) (py. self forward (py/get-item batch 0)))
))
"validation_step"
(py/make-tuple-instance-fn
(fn [self batch batch_idx]
(mse_loss (py/get-item batch 1) (py. self forward (py/get-item batch 0)))
))
"test_step"
(py/make-tuple-instance-fn
(fn [self batch batch_idx]
(mse_loss (py/get-item batch 1) (py. self forward (py/get-item batch 0)))
))
"configure_optimizers"
(py/make-tuple-instance-fn
(fn [self]
(torch.optim/SGD
(py. self parameters)
:lr 0.02)
))
}))
(def SimpleDataset
(py/create-class
"SimpleDataset" [Dataset]
{"__init__"
(py/make-tuple-instance-fn
(fn [self data] (py/set-attr! self "data" data) nil))
"__len__"
(py/make-tuple-instance-fn
(fn [self] (python/len (py.- self data))))
"__getitem__"
(py/make-tuple-instance-fn
(fn [self idx]
(py/->py-tuple
[
(torch/tensor [(py/get-item (py/get-item (py.- self data) idx) 0)] :dtype torch/float32)
(torch/tensor [(py/get-item (py/get-item (py.- self data) idx) 1)] :dtype torch/float32)
]
)
))
}))
(def SimpleDataModule
(py/create-class
"SimpleDataModule" [pytorch_lightning/LightningDataModule]
{"__init__"
(py/make-tuple-instance-fn
(fn [self data] (py/set-attr! self "data" data) nil))
"train_dataloader"
(py/make-tuple-instance-fn
(fn [self]
(DataLoader (SimpleDataset (py.- self data )) :batch_size 2 :shuffle false)))
"val_dataloader"
(py/make-tuple-instance-fn
(fn [self]
(DataLoader (SimpleDataset (py.- self data )) :batch_size 2 :shuffle false)))
"test_dataloader"
(py/make-tuple-instance-fn
(fn [self]
(DataLoader (SimpleDataset (py.- self data )) :batch_size 2 :shuffle false)))
}))
(defn -main [& args]
(reset! model (LitModel))
(def data [[1.0 3.0] [2.0 5.0] [3.0 7.0] [4.0 9.0] [5.0 11.0]] )
(def data_pylist (py/->py-list data))
;; (println (py/get-item (py/get-item data_pylist 0) 0))
(def train_dataset (SimpleDataset data_pylist))
(def train_loader (DataLoader train_dataset :batch_size 2 :shuffle false))
;; ;;for debug
;; (def train_pylist (python/list train_loader))
;; (def train_pylist_0 (py/get-item train_pylist 0))
;; (println (py. @model training_step train_pylist_0 0) );;;OK. maybe this part work
(def trainer (pytorch_lightning/Trainer :max_epochs 10 ))
(def datamodu (SimpleDataModule data_pylist))
(py. trainer fit @model train_loader)
;;(py. trainer fit @model datamodu) ;;also fail
)
- Ngôn ngữ chính
- Clojure
- Star
- 1.2k
- Fork
- 74
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của clj-python/libpython-clj
-
upgrade to dtype-next 11.xxx Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
clj-python/libpython-clj#280 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
clj-python/libpython-clj#275 · 5 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 58/100
clj-python/libpython-clj#273 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
clj-python/libpython-clj#271 · 1 bình luận ·
-
"auto flush" tty optionally Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
clj-python/libpython-clj#270 · 1 bình luận ·