LSTM, 셰익스피어 팬픽 쓰기 배우기

최근에 node.js와 tensorflow.js를 사용하여 셰익스피어의 일생에 대한 LSTM(장기 기억 네트워크)을 훈련했습니다. 유투브 비디오에 기록해 두었습니다. 말할 필요도 없이 꽤 흥미로운 것들을 만들어 냈습니다. 아래에는 교육 과정에서 얻은 텍스트 샘플이 있습니다. 영어 단어를 작성하고 스크립트를 구성하고 약간 이해할 수 있는 내용을 생성하는 방법도 배웠습니다.

내 LSTM에는 512개의 셀로 구성된 3개의 레이어가 있었고 10개의 문자가 과거로 표시되도록 했습니다. 출력 텍스트를 문자별로 생성했기 때문에 영어 단어를 스스로 배워야 했습니다.

1 부



시대 1:



단 한 번의 훈련 후에 LSTM은 알아낸 것이 별로 없습니다. 문자가 함께 그룹화되고 때때로 공백으로 구분된다는 것을 알고 있습니다.


RnDj.Rbecdti o-it oenzn t
rhittlt ,ete a oiet ,  a sottt ahitetoa   te    n n uio  r  struuoul l  in

시대 5:



Epoch 5까지 단어의 개념을 습득하고 개행을 효과적으로 사용하기 시작했습니다. 그 말은 여전히 ​​무의미하다.

F.$k
ahoetot   o  rt
t e e tn  h
oa md oe  i 
eta
s  e p  a t  
nm e ehsic ds e oe  oer    d e tu de

시대 9:



Epoch 9까지 신경망은 가장 일반적인 모음 소리를 생성하며 대부분은 발음할 수 있습니다.

vght
ste lo uat rie hoe en ha ae tu uare oo eo oe eio te ott oi hhe te hon. Cuo to ae tor  ha whn bw

에포크 10:



Epoch 10에서 생성하는 대부분은 넌센스지만 원격으로 영어로 보이는 첫 번째 문장을 생성합니다.

I thate hove moitee ou oa totte

에포크 15:



에포크 15까지 AI는 훨씬 더 잘하고 있습니다. 몇 가지 영어 단어를 생성합니다.

X3A'  ants rios we and yon heme on the bat in the pomite to renroe and his thered af the buth weth a

에포크 20:



에포크 20까지 AI는 셰익스피어의 "각본"구조를 학습했으며 그 개선이 상당히 중요합니다. 더 많은 영어 단어가 나타납니다.

COMINIUS:
Whe sons on thes fon on the bares
Than sot the comshes thes thon on ann he the thas os than to sast he dan theirs,
And anod.

COMINIUS:
The gowes the snades the ols with the fegins,
The getes burse the saurs bemoses thoy your than to son! Af the sorst me bud af you the paress.

MARsI:
MU thes than the an surn core these the secenss than they bathing hat the sirs that hears, and bures he as wert the peerss,
Ant nor then souts that wall the comtertet that wither.

에포크 50:



Epoch 20 이후에는 점진적으로 개선됩니다. 그러나 Epoch 50이 되자 생산되는 대부분의 단어는 영어이며 일부 문법 구조를 포착했습니다.

CLARENCER:
IURo:
I will no with the scrace his is the hore the stand his noble had enery the is Lore and he shall your gellow, he will 't: and you this are make think he wall bear him in my loved with his lrester the with his some.

CORIOLANUS:
Hear hand this a must that that that should have be him the made his mide and, and partion to the house that be lord with the would speak the world that is the generals and say besent me that I think me that are for the people
We have we is chacter this wifans,
A peace the should be mine stat with the meself the say the may your betord the might him that her in my with all the consareit.

CORIOLANUS:
Come, I know that his of here deserving, and his thou hath to cheass, and we did helcome be and made this noble dear the mare the wreed the mes the wide
And I think are the faunterang to must, and that no more the stard that he hast the shall me shall shall not be us mone that that this gase that that shall make I have me bear me maked his

에포크 100:



Epoch 100까지 많은 영어 단어를 배웠고 생성된 스크립트는 얼핏 보면 셰익스피어처럼 보일 수 있습니다.

MENENIUS:
Where is a matter; the people
Make the senator:
Whose the gods mother's tread the sons to the sourt to give his poppetions and the people, your solders the state the canter him be your wife the ploper to reash of him intent to should not so home and surperity him to might with him be the forter the come.

Second Conspirator:
And he was sach a soldier.

SICINIUS:
What, if the man if you the son,
The follows
fierte the gods to the people natery frame his reperity and the gods the gods the possed him voice and the markes and the cause to his fierter of more is Rome,
And, I do say the people the can son the state
As the condemned to be so the mother you

2 부



10자의 메모리 길이로 LSTM을 훈련시킨 후, 메모리를 20자로 확장하고 다시 훈련했습니다. 결과도 크게 다르지 않았다. 그래서 메모리를 50자로 확장하고 모델을 계속 훈련했습니다. 생성된 스크립트가 훨씬 더 좋아졌습니다.

시대 1:



처음에는 눈에 띄는 차이가 없습니다. 위조와 같은 더 큰 단어를 배웠다는 것을 알 수 있습니다.

Jraarfsaoft me was to sorrow not stay and not such as it
sounce:
The weeping met, the counterfeit an

에포크 10:



Epoch 10까지 스크립트가 훨씬 좋아졌습니다. 더 큰 메모리로 LSTM은 더 짧은 줄을 쓰고 일관된 주제를 유지하며 장면에 있는 사람을 추적할 수도 있습니다.
또한 "voomest"와 같은 재미있는 가짜 단어를 생성합니다.

FARCIUNIA:
I would they shall have now let me it is not the weard,
She would have not the stand on thee of the markys the preverent is your night.

CAREIA:
What are with will the friends, stay send our stranger'd the matter.

VALERIA:
Then they shall have been you quittle. I am a more with his dear forth
One our royal country on his grace of would proy,
There very in his dear, beoo the sun and the collery is his country.

CAREIA:
I will poor the voomest the warrant the house.

MARCIUS:
I am not, when it is not we present to die all I have been keep him forth so slive the lies in more them bear uson stir.

Second Senator:
I have for the stay madam, and I will be my son sho

신기원 30:



Epoch 30까지 대본은 실제로 셰익스피어처럼 들립니다. 거의 모든 단어가 영어로 되어 있으며 LSTM은 CORIOLANUS가 말을 멈춘 지 한참 뒤에 그 장면에 있다는 것을 인상적으로 기억합니다.

Second Citizen:
Then soul, which make you may a peace my death with your son the stebict them.

MENENIUS:
Which common the office the hols, and then not in his horse are the bold with the people, though you would leaves
be sprong him to be at the regarve the desire their better his hand to the people.

CORIOLANUS:
Ay, the then the part them: and first the sontent,
The sun with our worthy he shall should the consul.

First Senator:
I shall be man, the matters to the country may be the thing man be do their our with thee.

VOLUMNIA:
I have should you come, good mark us the man, whom
That is the common to the consul men't to be with not a sport.

CORIOLANUS:
O, it is not they shall as he hath a man's blood
With the proud. Where he content him stoble to gentles to be the sone to the

에포크 50:



여기에서 생성된 텍스트는 Epoch 30의 텍스트와 유사하지만 LSTM은 빠른 대화 라인 외에도 독백을 생성하는 방법을 배웠습니다.

COMINIUS:
Come, the bear come, the tribunes
I'ld be not be vanience to the common home the people.

CORIOLANUS:
Must of the show'd them.

SICINIUS:
My some house, what some and feel you me the common and to your
some own the meating, therefore a bear of thee be so head to breast
Than you see the war be so man a bear them
The dead to hear me see the some consider,
And the proved deven by the streech a common,
Come the mother whose mother?

CORIOLANUS:

SICINIUS:
I have speak be so shill for whose head,
The prithee see him they be not some with
the sent to take a speak them them my shall
I have precend so that you shall be continues
The voices with the people, they come,
And but he that the power hath we me here the stroke my man the people
That whoo's stand of the words, and now
The noble house thee with me this hither.

CORIOLANUS:
I know the selt him the strength.

CORIOLANUS:
I would be consul
The one but a come, and

에포크 100:



Epoch 50 이후 LSTM의 성능은 평준화되었습니다. 생성된 "Murderer"스크립트는 종료를 위해 여기에 있습니다(또한 꽤 괜찮은 스크립트입니다 - 하하).

First Murderer:
I have done to him, then the man have much in the counsel,
When thou shalt not sent to the queen,
And the curse to have down the angel and the world
see the sun of the reasons so sent to see the remompy.

First Murderer:
Mary man!

CLARENCE:
Alas the mother to the air,
I have done to the death of shines, and his lawful.

First Murderer:
I will not shall not the business with a warrant the man
The such a dayn from him his absence for thy disconeen and offence
To the presence and still the reason to give
The world of did of heart me of men to the world
To see you in the hatchens to the stabbed for my world of clarge.

First Murderer:
To friends to meaning that thou art thou hadst ender peace.

Second Murderer:
So will not have saw to medness so he honour
To entertain with me on the sword, and the heaven.

마지막 스크립트...



LSTM에 의해 생성된 특히 재미있는 스크립트는 "사람"에 대해 이야기합니다... 많이:

MENENIUS:
Sir, comes when the people!

MENENIUS:
Do you a persons
That have not sword in the people end
That shall for the people.

COMINIUS:
What cause the people vail to the people
What you will be consul, the people.

SICINIUS:
Hear me death him to make the people!

MENENIUS:
No, no, be consul.

COMINIUS:
Nay, you shall therefore, sir, the people,
Which you should the one that the gracing for the wise the sun
Of the march of the people in the people.

COMINIUS:
You are to the people,
When he will the varture of the people his senate
That is the consul of your best
And sure of the honours they worthy little that is the death.

MENENIUS:
Therefore so are in the noble worthy request
The ground was take the people though the lattle and bench
That you shall to make the consent of the voices
What shall many in their proud to cold prosperous
True his found of the people,
Be content of the people.

그리고 그 놀라운 문학 작품을 여러분께 남겨 드리겠습니다. 제 LSTM의 재미있는 결과를 재미있게 보셨기를 바랍니다. 읽어 주셔서 감사합니다!

좋은 웹페이지 즐겨찾기