Skip to content

Commit 88b9b2b

Browse files
committed
working !!
1 parent 66c5adb commit 88b9b2b

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

simpletransformers.clj

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
(ns scicloj.ml.simpletransformers)
1+
(ns scicloj.ml.simpletransformers
2+
(:require [libpython-clj2.python :refer [py.- py.] :as py]))
3+
24

3-
(require '[libpython-clj2.require :as py-req]
4-
'[libpython-clj2.python.io-redirect]
5-
'[libpython-clj2.python :refer [py.- py.] :as py])
65

76

87

9-
(py/from-import simpletransformers.classification ClassificationModel)
10-
(py-req/require-python '[pandas :as pd])
118

129
(def train-data [
1310
["Example sentence belonging to class 1" 1]
@@ -21,18 +18,24 @@
2118

2219

2320
(println "train...")
21+
(py/with-gil-stack-rc-context
22+
23+
(py/from-import simpletransformers.classification ClassificationModel)
24+
25+
2426

25-
(let [
26-
train-df (pd/DataFrame train-data)
27-
eval-df (pd/DataFrame eval-data)
27+
(let [
28+
pd (py/import-module "pandas")
29+
train-df (py. pd DataFrame train-data)
30+
eval-df (py. pd DataFrame eval-data)
2831

29-
model (ClassificationModel "bert" "prajjwal1/bert-tiny" :use_cuda false :args
30-
{:num_train_epochs 1
31-
:use_multiprocessing false
32-
:overwrite_output_dir true})
32+
model (ClassificationModel "bert" "prajjwal1/bert-tiny" :use_cuda false :args
33+
{:num_train_epochs 1
34+
:use_multiprocessing false
35+
:overwrite_output_dir true})
3336

3437

35-
x (py. model train_model train-df)]
36-
(println x))
38+
x (py. model train_model train-df)]
39+
(println x)))
3740

3841
(println "finished train")

0 commit comments

Comments
 (0)