21
21
initimages! (wc, i; kargs... ) = initimage! .(wc, index (wc, i); kargs... )
22
22
function initimages! (wc:: WC ; maxiter= 5 , error= 0.02 )
23
23
params = wc. params
24
- mask = wc. mask
25
24
26
25
si = sortperm (wc. weights, rev= true )
27
26
words = wc. words[si]
@@ -151,7 +150,14 @@ function recolor!(wc, args...; style=:average, kargs...)
151
150
end
152
151
nothing
153
152
end
154
-
153
+ """
154
+ # Positional Args
155
+ * wc: the wordcloud to fit
156
+ * nepoch: training epoch nums
157
+ # Keyword Args
158
+ * patient: number of epochs before teleporting, set to `-1` to disable teleporting
159
+ * trainer: appoint a training engine
160
+ """
155
161
function fit! (wc, args... ; krags... )
156
162
if STATEIDS[getstate (wc)] < STATEIDS[:placement! ]
157
163
placement! (wc)
@@ -161,6 +167,8 @@ function fit!(wc, args...; krags...)
161
167
wc. params[:epoch ] += ep
162
168
if nc == 0
163
169
setstate! (wc, nameof (fit!))
170
+ else
171
+ setstate! (wc, nameof (placement!))
164
172
end
165
173
wc
166
174
end
@@ -177,7 +185,7 @@ function printcollisions(wc)
177
185
end
178
186
"""
179
187
# Positional Args
180
- * wc: the wordcloud to train
188
+ * wc: the wordcloud to fit
181
189
* nepoch: training epoch nums
182
190
# Keyword Args
183
191
* retry: shrink & retrain times, defaults to 3, set to `1` to disable shrinking
@@ -188,11 +196,9 @@ function generate!(wc::WC, args...; retry=3, krags...)
188
196
if STATEIDS[getstate (wc)] < STATEIDS[:placement! ]
189
197
placement! (wc)
190
198
end
191
- ep, nc = - 1 , - 1
192
199
for r in 1 : retry
193
200
if r != 1
194
201
rescale! (wc, 0.97 )
195
- qtrees = [wc. maskqtree, wc. qtrees... ]
196
202
dens = textoccupied (getwords (wc), getfontsizes (wc), getfonts (wc))/ wc. params[:groundoccupied ]
197
203
println (" #$r . try scale = $(wc. params[:scale ]) . The density is reduced to $dens " )
198
204
else
0 commit comments