tepechin_kirill_lab_7
61
tepechin_kirill_lab_7/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
## Лабораторная работа №7, ПИбд-42 Тепечин Кирилл
|
||||
|
||||
|
||||
### Как запустить лабораторную работу:
|
||||
|
||||
Для запуска лабораторной работы необходимо запустить файл lab7.py
|
||||
|
||||
### Используемые технологии:
|
||||
|
||||
* Python 3.11
|
||||
* numpy
|
||||
* keras
|
||||
|
||||
### Что делает лабораторная работа:
|
||||
|
||||
Эта лабораторная работа создает и обучает рекуррентную нейронную сеть (RNN) на основе текста из файла, используя библиотеку Keras.
|
||||
|
||||
### Тесты:
|
||||
Опытным путем была выбрана следующая архитектура:
|
||||
````python
|
||||
model = Sequential()
|
||||
model.add(Embedding(total_words, 50, input_length=max_sequence_length - 1))
|
||||
model.add(LSTM(512))
|
||||
model.add(Dropout(0.2))
|
||||
model.add(Dense(total_words, activation='softmax'))
|
||||
````
|
||||
|
||||
Результат на 50 эпохах
|
||||
|
||||
![тест1](test1.png)
|
||||
|
||||
![тест1](test1_text.png)
|
||||
|
||||
Результат становится гораздо лучше при увеличении количества эпох
|
||||
|
||||
Результат на 200 эпохах
|
||||
|
||||
![тест2](test2.png)
|
||||
|
||||
![тест2](test2_text.png)
|
||||
|
||||
На англоязычном тексте сеть работает хуже (50 эпох)
|
||||
|
||||
![тест3](test3.png)
|
||||
|
||||
Хоть и текст выглядит не так плохо
|
||||
|
||||
![тест3](test3_text.png)
|
||||
|
||||
На 200 эпох результат практически не улучшается
|
||||
|
||||
![тест4](test4.png)
|
||||
|
||||
Но текст выглядит более осмысленно
|
||||
|
||||
![тест4](test4_text.png)
|
||||
|
||||
Последующие поиски компромиссной архитектуры не привели к появлению новой.
|
||||
|
||||
### Вывод:
|
||||
Компромиссной архитектурой является ранее выбранная
|
582
tepechin_kirill_lab_7/engtext.txt
Normal file
@ -0,0 +1,582 @@
|
||||
CYMBELINE. Stand by my side, you whom the gods have made
|
||||
Preservers of my throne. Woe is my heart
|
||||
That the poor soldier that so richly fought,
|
||||
Whose rags sham'd gilded arms, whose naked breast
|
||||
Stepp'd before targes of proof, cannot be found.
|
||||
He shall be happy that can find him, if
|
||||
Our grace can make him so.
|
||||
BELARIUS. I never saw
|
||||
Such noble fury in so poor a thing;
|
||||
Such precious deeds in one that promis'd nought
|
||||
But beggary and poor looks.
|
||||
CYMBELINE. No tidings of him?
|
||||
PISANIO. He hath been search'd among the dead and living,
|
||||
But no trace of him.
|
||||
CYMBELINE. To my grief, I am
|
||||
The heir of his reward; [To BELARIUS, GUIDERIUS, and ARVIRAGUS]
|
||||
which I will add
|
||||
To you, the liver, heart, and brain, of Britain,
|
||||
By whom I grant she lives. 'Tis now the time
|
||||
To ask of whence you are. Report it.
|
||||
BELARIUS. Sir,
|
||||
In Cambria are we born, and gentlemen;
|
||||
Further to boast were neither true nor modest,
|
||||
Unless I add we are honest.
|
||||
CYMBELINE. Bow your knees.
|
||||
Arise my knights o' th' battle; I create you
|
||||
Companions to our person, and will fit you
|
||||
With dignities becoming your estates.
|
||||
|
||||
Enter CORNELIUS and LADIES
|
||||
|
||||
There's business in these faces. Why so sadly
|
||||
Greet you our victory? You look like Romans,
|
||||
And not o' th' court of Britain.
|
||||
CORNELIUS. Hail, great King!
|
||||
To sour your happiness I must report
|
||||
The Queen is dead.
|
||||
CYMBELINE. Who worse than a physician
|
||||
Would this report become? But I consider
|
||||
By med'cine'life may be prolong'd, yet death
|
||||
Will seize the doctor too. How ended she?
|
||||
CORNELIUS. With horror, madly dying, like her life;
|
||||
Which, being cruel to the world, concluded
|
||||
Most cruel to herself. What she confess'd
|
||||
I will report, so please you; these her women
|
||||
Can trip me if I err, who with wet cheeks
|
||||
Were present when she finish'd.
|
||||
CYMBELINE. Prithee say.
|
||||
CORNELIUS. First, she confess'd she never lov'd you; only
|
||||
Affected greatness got by you, not you;
|
||||
Married your royalty, was wife to your place;
|
||||
Abhorr'd your person.
|
||||
CYMBELINE. She alone knew this;
|
||||
And but she spoke it dying, I would not
|
||||
Believe her lips in opening it. Proceed.
|
||||
CORNELIUS. Your daughter, whom she bore in hand to love
|
||||
With such integrity, she did confess
|
||||
Was as a scorpion to her sight; whose life,
|
||||
But that her flight prevented it, she had
|
||||
Ta'en off by poison.
|
||||
CYMBELINE. O most delicate fiend!
|
||||
Who is't can read a woman? Is there more?
|
||||
CORNELIUS. More, sir, and worse. She did confess she had
|
||||
For you a mortal mineral, which, being took,
|
||||
Should by the minute feed on life, and ling'ring,
|
||||
By inches waste you. In which time she purpos'd,
|
||||
By watching, weeping, tendance, kissing, to
|
||||
O'ercome you with her show; and in time,
|
||||
When she had fitted you with her craft, to work
|
||||
Her son into th' adoption of the crown;
|
||||
But failing of her end by his strange absence,
|
||||
Grew shameless-desperate, open'd, in despite
|
||||
Of heaven and men, her purposes, repented
|
||||
The evils she hatch'd were not effected; so,
|
||||
Despairing, died.
|
||||
CYMBELINE. Heard you all this, her women?
|
||||
LADY. We did, so please your Highness.
|
||||
CYMBELINE. Mine eyes
|
||||
Were not in fault, for she was beautiful;
|
||||
Mine ears, that heard her flattery; nor my heart
|
||||
That thought her like her seeming. It had been vicious
|
||||
To have mistrusted her; yet, O my daughter!
|
||||
That it was folly in me thou mayst say,
|
||||
And prove it in thy feeling. Heaven mend all!
|
||||
|
||||
Enter LUCIUS, IACHIMO, the SOOTHSAYER, and other
|
||||
Roman prisoners, guarded; POSTHUMUS behind, and IMOGEN
|
||||
|
||||
Thou com'st not, Caius, now for tribute; that
|
||||
The Britons have raz'd out, though with the loss
|
||||
Of many a bold one, whose kinsmen have made suit
|
||||
That their good souls may be appeas'd with slaughter
|
||||
Of you their captives, which ourself have granted;
|
||||
So think of your estate.
|
||||
LUCIUS. Consider, sir, the chance of war. The day
|
||||
Was yours by accident; had it gone with us,
|
||||
We should not, when the blood was cool, have threaten'd
|
||||
Our prisoners with the sword. But since the gods
|
||||
Will have it thus, that nothing but our lives
|
||||
May be call'd ransom, let it come. Sufficeth
|
||||
A Roman with a Roman's heart can suffer.
|
||||
Augustus lives to think on't; and so much
|
||||
For my peculiar care. This one thing only
|
||||
I will entreat: my boy, a Briton born,
|
||||
Let him be ransom'd. Never master had
|
||||
A page so kind, so duteous, diligent,
|
||||
So tender over his occasions, true,
|
||||
So feat, so nurse-like; let his virtue join
|
||||
With my request, which I'll make bold your Highness
|
||||
Cannot deny; he hath done no Briton harm
|
||||
Though he have serv'd a Roman. Save him, sir,
|
||||
And spare no blood beside.
|
||||
CYMBELINE. I have surely seen him;
|
||||
His favour is familiar to me. Boy,
|
||||
Thou hast look'd thyself into my grace,
|
||||
And art mine own. I know not why, wherefore
|
||||
To say 'Live, boy.' Ne'er thank thy master. Live;
|
||||
And ask of Cymbeline what boon thou wilt,
|
||||
Fitting my bounty and thy state, I'll give it;
|
||||
Yea, though thou do demand a prisoner,
|
||||
The noblest ta'en.
|
||||
IMOGEN. I humbly thank your Highness.
|
||||
LUCIUS. I do not bid thee beg my life, good lad,
|
||||
And yet I know thou wilt.
|
||||
IMOGEN. No, no! Alack,
|
||||
There's other work in hand. I see a thing
|
||||
Bitter to me as death; your life, good master,
|
||||
Must shuffle for itself.
|
||||
LUCIUS. The boy disdains me,
|
||||
He leaves me, scorns me. Briefly die their joys
|
||||
That place them on the truth of girls and boys.
|
||||
Why stands he so perplex'd?
|
||||
CYMBELINE. What wouldst thou, boy?
|
||||
I love thee more and more; think more and more
|
||||
What's best to ask. Know'st him thou look'st on? Speak,
|
||||
Wilt have him live? Is he thy kin? thy friend?
|
||||
IMOGEN. He is a Roman, no more kin to me
|
||||
Than I to your Highness; who, being born your vassal,
|
||||
Am something nearer.
|
||||
CYMBELINE. Wherefore ey'st him so?
|
||||
IMOGEN. I'll tell you, sir, in private, if you please
|
||||
To give me hearing.
|
||||
CYMBELINE. Ay, with all my heart,
|
||||
And lend my best attention. What's thy name?
|
||||
IMOGEN. Fidele, sir.
|
||||
CYMBELINE. Thou'rt my good youth, my page;
|
||||
I'll be thy master. Walk with me; speak freely.
|
||||
[CYMBELINE and IMOGEN converse apart]
|
||||
BELARIUS. Is not this boy reviv'd from death?
|
||||
ARVIRAGUS. One sand another
|
||||
Not more resembles- that sweet rosy lad
|
||||
Who died and was Fidele. What think you?
|
||||
GUIDERIUS. The same dead thing alive.
|
||||
BELARIUS. Peace, peace! see further. He eyes us not; forbear.
|
||||
Creatures may be alike; were't he, I am sure
|
||||
He would have spoke to us.
|
||||
GUIDERIUS. But we saw him dead.
|
||||
BELARIUS. Be silent; let's see further.
|
||||
PISANIO. [Aside] It is my mistress.
|
||||
Since she is living, let the time run on
|
||||
To good or bad. [CYMBELINE and IMOGEN advance]
|
||||
CYMBELINE. Come, stand thou by our side;
|
||||
Make thy demand aloud. [To IACHIMO] Sir, step you forth;
|
||||
Give answer to this boy, and do it freely,
|
||||
Or, by our greatness and the grace of it,
|
||||
Which is our honour, bitter torture shall
|
||||
Winnow the truth from falsehood. On, speak to him.
|
||||
IMOGEN. My boon is that this gentleman may render
|
||||
Of whom he had this ring.
|
||||
POSTHUMUS. [Aside] What's that to him?
|
||||
CYMBELINE. That diamond upon your finger, say
|
||||
How came it yours?
|
||||
IACHIMO. Thou'lt torture me to leave unspoken that
|
||||
Which to be spoke would torture thee.
|
||||
CYMBELINE. How? me?
|
||||
IACHIMO. I am glad to be constrain'd to utter that
|
||||
Which torments me to conceal. By villainy
|
||||
I got this ring; 'twas Leonatus' jewel,
|
||||
Whom thou didst banish; and- which more may grieve thee,
|
||||
As it doth me- a nobler sir ne'er liv'd
|
||||
'Twixt sky and ground. Wilt thou hear more, my lord?
|
||||
CYMBELINE. All that belongs to this.
|
||||
IACHIMO. That paragon, thy daughter,
|
||||
For whom my heart drops blood and my false spirits
|
||||
Quail to remember- Give me leave, I faint.
|
||||
CYMBELINE. My daughter? What of her? Renew thy strength;
|
||||
I had rather thou shouldst live while nature will
|
||||
Than die ere I hear more. Strive, man, and speak.
|
||||
IACHIMO. Upon a time- unhappy was the clock
|
||||
That struck the hour!- was in Rome- accurs'd
|
||||
The mansion where!- 'twas at a feast- O, would
|
||||
Our viands had been poison'd, or at least
|
||||
Those which I heav'd to head!- the good Posthumus-
|
||||
What should I say? he was too good to be
|
||||
Where ill men were, and was the best of all
|
||||
Amongst the rar'st of good ones- sitting sadly
|
||||
Hearing us praise our loves of Italy
|
||||
For beauty that made barren the swell'd boast
|
||||
Of him that best could speak; for feature, laming
|
||||
The shrine of Venus or straight-pight Minerva,
|
||||
Postures beyond brief nature; for condition,
|
||||
A shop of all the qualities that man
|
||||
Loves woman for; besides that hook of wiving,
|
||||
Fairness which strikes the eye-
|
||||
CYMBELINE. I stand on fire.
|
||||
Come to the matter.
|
||||
IACHIMO. All too soon I shall,
|
||||
Unless thou wouldst grieve quickly. This Posthumus,
|
||||
Most like a noble lord in love and one
|
||||
That had a royal lover, took his hint;
|
||||
And not dispraising whom we prais'd- therein
|
||||
He was as calm as virtue- he began
|
||||
His mistress' picture; which by his tongue being made,
|
||||
And then a mind put in't, either our brags
|
||||
Were crack'd of kitchen trulls, or his description
|
||||
Prov'd us unspeaking sots.
|
||||
CYMBELINE. Nay, nay, to th' purpose.
|
||||
IACHIMO. Your daughter's chastity- there it begins.
|
||||
He spake of her as Dian had hot dreams
|
||||
And she alone were cold; whereat I, wretch,
|
||||
Made scruple of his praise, and wager'd with him
|
||||
Pieces of gold 'gainst this which then he wore
|
||||
Upon his honour'd finger, to attain
|
||||
In suit the place of's bed, and win this ring
|
||||
By hers and mine adultery. He, true knight,
|
||||
No lesser of her honour confident
|
||||
Than I did truly find her, stakes this ring;
|
||||
And would so, had it been a carbuncle
|
||||
Of Phoebus' wheel; and might so safely, had it
|
||||
Been all the worth of's car. Away to Britain
|
||||
Post I in this design. Well may you, sir,
|
||||
Remember me at court, where I was taught
|
||||
Of your chaste daughter the wide difference
|
||||
'Twixt amorous and villainous. Being thus quench'd
|
||||
Of hope, not longing, mine Italian brain
|
||||
Gan in your duller Britain operate
|
||||
Most vilely; for my vantage, excellent;
|
||||
And, to be brief, my practice so prevail'd
|
||||
That I return'd with simular proof enough
|
||||
To make the noble Leonatus mad,
|
||||
By wounding his belief in her renown
|
||||
With tokens thus and thus; averring notes
|
||||
Of chamber-hanging, pictures, this her bracelet-
|
||||
O cunning, how I got it!- nay, some marks
|
||||
Of secret on her person, that he could not
|
||||
But think her bond of chastity quite crack'd,
|
||||
I having ta'en the forfeit. Whereupon-
|
||||
Methinks I see him now-
|
||||
POSTHUMUS. [Coming forward] Ay, so thou dost,
|
||||
Italian fiend! Ay me, most credulous fool,
|
||||
Egregious murderer, thief, anything
|
||||
That's due to all the villains past, in being,
|
||||
To come! O, give me cord, or knife, or poison,
|
||||
Some upright justicer! Thou, King, send out
|
||||
For torturers ingenious. It is I
|
||||
That all th' abhorred things o' th' earth amend
|
||||
By being worse than they. I am Posthumus,
|
||||
That kill'd thy daughter; villain-like, I lie-
|
||||
That caus'd a lesser villain than myself,
|
||||
A sacrilegious thief, to do't. The temple
|
||||
Of virtue was she; yea, and she herself.
|
||||
Spit, and throw stones, cast mire upon me, set
|
||||
The dogs o' th' street to bay me. Every villain
|
||||
Be call'd Posthumus Leonatus, and
|
||||
Be villainy less than 'twas! O Imogen!
|
||||
My queen, my life, my wife! O Imogen,
|
||||
Imogen, Imogen!
|
||||
IMOGEN. Peace, my lord. Hear, hear!
|
||||
POSTHUMUS. Shall's have a play of this? Thou scornful page,
|
||||
There lies thy part. [Strikes her. She falls]
|
||||
PISANIO. O gentlemen, help!
|
||||
Mine and your mistress! O, my lord Posthumus!
|
||||
You ne'er kill'd Imogen till now. Help, help!
|
||||
Mine honour'd lady!
|
||||
CYMBELINE. Does the world go round?
|
||||
POSTHUMUS. How comes these staggers on me?
|
||||
PISANIO. Wake, my mistress!
|
||||
CYMBELINE. If this be so, the gods do mean to strike me
|
||||
To death with mortal joy.
|
||||
PISANIO. How fares my mistress?
|
||||
IMOGEN. O, get thee from my sight;
|
||||
Thou gav'st me poison. Dangerous fellow, hence!
|
||||
Breathe not where princes are.
|
||||
CYMBELINE. The tune of Imogen!
|
||||
PISANIO. Lady,
|
||||
The gods throw stones of sulphur on me, if
|
||||
That box I gave you was not thought by me
|
||||
A precious thing! I had it from the Queen.
|
||||
CYMBELINE. New matter still?
|
||||
IMOGEN. It poison'd me.
|
||||
CORNELIUS. O gods!
|
||||
I left out one thing which the Queen confess'd,
|
||||
Which must approve thee honest. 'If Pisanio
|
||||
Have' said she 'given his mistress that confection
|
||||
Which I gave him for cordial, she is serv'd
|
||||
As I would serve a rat.'
|
||||
CYMBELINE. What's this, Cornelius?
|
||||
CORNELIUS. The Queen, sir, very oft importun'd me
|
||||
To temper poisons for her; still pretending
|
||||
The satisfaction of her knowledge only
|
||||
In killing creatures vile, as cats and dogs,
|
||||
Of no esteem. I, dreading that her purpose
|
||||
Was of more danger, did compound for her
|
||||
A certain stuff, which, being ta'en would cease
|
||||
The present pow'r of life, but in short time
|
||||
All offices of nature should again
|
||||
Do their due functions. Have you ta'en of it?
|
||||
IMOGEN. Most like I did, for I was dead.
|
||||
BELARIUS. My boys,
|
||||
There was our error.
|
||||
GUIDERIUS. This is sure Fidele.
|
||||
IMOGEN. Why did you throw your wedded lady from you?
|
||||
Think that you are upon a rock, and now
|
||||
Throw me again. [Embracing him]
|
||||
POSTHUMUS. Hang there like fruit, my soul,
|
||||
Till the tree die!
|
||||
CYMBELINE. How now, my flesh? my child?
|
||||
What, mak'st thou me a dullard in this act?
|
||||
Wilt thou not speak to me?
|
||||
IMOGEN. [Kneeling] Your blessing, sir.
|
||||
BELARIUS. [To GUIDERIUS and ARVIRAGUS] Though you did love this
|
||||
youth, I blame ye not;
|
||||
You had a motive for't.
|
||||
CYMBELINE. My tears that fall
|
||||
Prove holy water on thee! Imogen,
|
||||
Thy mother's dead.
|
||||
IMOGEN. I am sorry for't, my lord.
|
||||
CYMBELINE. O, she was naught, and long of her it was
|
||||
That we meet here so strangely; but her son
|
||||
Is gone, we know not how nor where.
|
||||
PISANIO. My lord,
|
||||
Now fear is from me, I'll speak troth. Lord Cloten,
|
||||
Upon my lady's missing, came to me
|
||||
With his sword drawn, foam'd at the mouth, and swore,
|
||||
If I discover'd not which way she was gone,
|
||||
It was my instant death. By accident
|
||||
I had a feigned letter of my master's
|
||||
Then in my pocket, which directed him
|
||||
To seek her on the mountains near to Milford;
|
||||
Where, in a frenzy, in my master's garments,
|
||||
Which he enforc'd from me, away he posts
|
||||
With unchaste purpose, and with oath to violate
|
||||
My lady's honour. What became of him
|
||||
I further know not.
|
||||
GUIDERIUS. Let me end the story:
|
||||
I slew him there.
|
||||
CYMBELINE. Marry, the gods forfend!
|
||||
I would not thy good deeds should from my lips
|
||||
Pluck a hard sentence. Prithee, valiant youth,
|
||||
Deny't again.
|
||||
GUIDERIUS. I have spoke it, and I did it.
|
||||
CYMBELINE. He was a prince.
|
||||
GUIDERIUS. A most incivil one. The wrongs he did me
|
||||
Were nothing prince-like; for he did provoke me
|
||||
With language that would make me spurn the sea,
|
||||
If it could so roar to me. I cut off's head,
|
||||
And am right glad he is not standing here
|
||||
To tell this tale of mine.
|
||||
CYMBELINE. I am sorry for thee.
|
||||
By thine own tongue thou art condemn'd, and must
|
||||
Endure our law. Thou'rt dead.
|
||||
IMOGEN. That headless man
|
||||
I thought had been my lord.
|
||||
CYMBELINE. Bind the offender,
|
||||
And take him from our presence.
|
||||
BELARIUS. Stay, sir King.
|
||||
This man is better than the man he slew,
|
||||
As well descended as thyself, and hath
|
||||
More of thee merited than a band of Clotens
|
||||
Had ever scar for. [To the guard] Let his arms alone;
|
||||
They were not born for bondage.
|
||||
CYMBELINE. Why, old soldier,
|
||||
Wilt thou undo the worth thou art unpaid for
|
||||
By tasting of our wrath? How of descent
|
||||
As good as we?
|
||||
ARVIRAGUS. In that he spake too far.
|
||||
CYMBELINE. And thou shalt die for't.
|
||||
BELARIUS. We will die all three;
|
||||
But I will prove that two on's are as good
|
||||
As I have given out him. My sons, I must
|
||||
For mine own part unfold a dangerous speech,
|
||||
Though haply well for you.
|
||||
ARVIRAGUS. Your danger's ours.
|
||||
GUIDERIUS. And our good his.
|
||||
BELARIUS. Have at it then by leave!
|
||||
Thou hadst, great King, a subject who
|
||||
Was call'd Belarius.
|
||||
CYMBELINE. What of him? He is
|
||||
A banish'd traitor.
|
||||
BELARIUS. He it is that hath
|
||||
Assum'd this age; indeed a banish'd man;
|
||||
I know not how a traitor.
|
||||
CYMBELINE. Take him hence,
|
||||
The whole world shall not save him.
|
||||
BELARIUS. Not too hot.
|
||||
First pay me for the nursing of thy sons,
|
||||
And let it be confiscate all, so soon
|
||||
As I have receiv'd it.
|
||||
CYMBELINE. Nursing of my sons?
|
||||
BELARIUS. I am too blunt and saucy: here's my knee.
|
||||
Ere I arise I will prefer my sons;
|
||||
Then spare not the old father. Mighty sir,
|
||||
These two young gentlemen that call me father,
|
||||
And think they are my sons, are none of mine;
|
||||
They are the issue of your loins, my liege,
|
||||
And blood of your begetting.
|
||||
CYMBELINE. How? my issue?
|
||||
BELARIUS. So sure as you your father's. I, old Morgan,
|
||||
Am that Belarius whom you sometime banish'd.
|
||||
Your pleasure was my mere offence, my punishment
|
||||
Itself, and all my treason; that I suffer'd
|
||||
Was all the harm I did. These gentle princes-
|
||||
For such and so they are- these twenty years
|
||||
Have I train'd up; those arts they have as
|
||||
Could put into them. My breeding was, sir, as
|
||||
Your Highness knows. Their nurse, Euriphile,
|
||||
Whom for the theft I wedded, stole these children
|
||||
Upon my banishment; I mov'd her to't,
|
||||
Having receiv'd the punishment before
|
||||
For that which I did then. Beaten for loyalty
|
||||
Excited me to treason. Their dear loss,
|
||||
The more of you 'twas felt, the more it shap'd
|
||||
Unto my end of stealing them. But, gracious sir,
|
||||
Here are your sons again, and I must lose
|
||||
Two of the sweet'st companions in the world.
|
||||
The benediction of these covering heavens
|
||||
Fall on their heads like dew! for they are worthy
|
||||
To inlay heaven with stars.
|
||||
CYMBELINE. Thou weep'st and speak'st.
|
||||
The service that you three have done is more
|
||||
Unlike than this thou tell'st. I lost my children.
|
||||
If these be they, I know not how to wish
|
||||
A pair of worthier sons.
|
||||
BELARIUS. Be pleas'd awhile.
|
||||
This gentleman, whom I call Polydore,
|
||||
Most worthy prince, as yours, is true Guiderius;
|
||||
This gentleman, my Cadwal, Arviragus,
|
||||
Your younger princely son; he, sir, was lapp'd
|
||||
In a most curious mantle, wrought by th' hand
|
||||
Of his queen mother, which for more probation
|
||||
I can with ease produce.
|
||||
CYMBELINE. Guiderius had
|
||||
Upon his neck a mole, a sanguine star;
|
||||
It was a mark of wonder.
|
||||
BELARIUS. This is he,
|
||||
Who hath upon him still that natural stamp.
|
||||
It was wise nature's end in the donation,
|
||||
To be his evidence now.
|
||||
CYMBELINE. O, what am I?
|
||||
A mother to the birth of three? Ne'er mother
|
||||
Rejoic'd deliverance more. Blest pray you be,
|
||||
That, after this strange starting from your orbs,
|
||||
You may reign in them now! O Imogen,
|
||||
Thou hast lost by this a kingdom.
|
||||
IMOGEN. No, my lord;
|
||||
I have got two worlds by't. O my gentle brothers,
|
||||
Have we thus met? O, never say hereafter
|
||||
But I am truest speaker! You call'd me brother,
|
||||
When I was but your sister: I you brothers,
|
||||
When we were so indeed.
|
||||
CYMBELINE. Did you e'er meet?
|
||||
ARVIRAGUS. Ay, my good lord.
|
||||
GUIDERIUS. And at first meeting lov'd,
|
||||
Continu'd so until we thought he died.
|
||||
CORNELIUS. By the Queen's dram she swallow'd.
|
||||
CYMBELINE. O rare instinct!
|
||||
When shall I hear all through? This fierce abridgment
|
||||
Hath to it circumstantial branches, which
|
||||
Distinction should be rich in. Where? how liv'd you?
|
||||
And when came you to serve our Roman captive?
|
||||
How parted with your brothers? how first met them?
|
||||
Why fled you from the court? and whither? These,
|
||||
And your three motives to the battle, with
|
||||
I know not how much more, should be demanded,
|
||||
And all the other by-dependences,
|
||||
From chance to chance; but nor the time nor place
|
||||
Will serve our long interrogatories. See,
|
||||
Posthumus anchors upon Imogen;
|
||||
And she, like harmless lightning, throws her eye
|
||||
On him, her brothers, me, her master, hitting
|
||||
Each object with a joy; the counterchange
|
||||
Is severally in all. Let's quit this ground,
|
||||
And smoke the temple with our sacrifices.
|
||||
[To BELARIUS] Thou art my brother; so we'll hold thee ever.
|
||||
IMOGEN. You are my father too, and did relieve me
|
||||
To see this gracious season.
|
||||
CYMBELINE. All o'erjoy'd
|
||||
Save these in bonds. Let them be joyful too,
|
||||
For they shall taste our comfort.
|
||||
IMOGEN. My good master,
|
||||
I will yet do you service.
|
||||
LUCIUS. Happy be you!
|
||||
CYMBELINE. The forlorn soldier, that so nobly fought,
|
||||
He would have well becom'd this place and grac'd
|
||||
The thankings of a king.
|
||||
POSTHUMUS. I am, sir,
|
||||
The soldier that did company these three
|
||||
In poor beseeming; 'twas a fitment for
|
||||
The purpose I then follow'd. That I was he,
|
||||
Speak, Iachimo. I had you down, and might
|
||||
Have made you finish.
|
||||
IACHIMO. [Kneeling] I am down again;
|
||||
But now my heavy conscience sinks my knee,
|
||||
As then your force did. Take that life, beseech you,
|
||||
Which I so often owe; but your ring first,
|
||||
And here the bracelet of the truest princess
|
||||
That ever swore her faith.
|
||||
POSTHUMUS. Kneel not to me.
|
||||
The pow'r that I have on you is to spare you;
|
||||
The malice towards you to forgive you. Live,
|
||||
And deal with others better.
|
||||
CYMBELINE. Nobly doom'd!
|
||||
We'll learn our freeness of a son-in-law;
|
||||
Pardon's the word to all.
|
||||
ARVIRAGUS. You holp us, sir,
|
||||
As you did mean indeed to be our brother;
|
||||
Joy'd are we that you are.
|
||||
POSTHUMUS. Your servant, Princes. Good my lord of Rome,
|
||||
Call forth your soothsayer. As I slept, methought
|
||||
Great Jupiter, upon his eagle back'd,
|
||||
Appear'd to me, with other spritely shows
|
||||
Of mine own kindred. When I wak'd, I found
|
||||
This label on my bosom; whose containing
|
||||
Is so from sense in hardness that I can
|
||||
Make no collection of it. Let him show
|
||||
His skill in the construction.
|
||||
LUCIUS. Philarmonus!
|
||||
SOOTHSAYER. Here, my good lord.
|
||||
LUCIUS. Read, and declare the meaning.
|
||||
SOOTHSAYER. [Reads] 'When as a lion's whelp shall, to himself
|
||||
unknown, without seeking find, and be embrac'd by
|
||||
a piece of tender air; and when from a stately cedar shall
|
||||
be lopp'd branches which, being dead many years, shall
|
||||
after revive, be jointed to the old stock, and freshly grow;
|
||||
then shall Posthumus end his miseries, Britain be fortunate
|
||||
and flourish in peace and plenty.'
|
||||
Thou, Leonatus, art the lion's whelp;
|
||||
The fit and apt construction of thy name,
|
||||
Being Leo-natus, doth import so much.
|
||||
[To CYMBELINE] The piece of tender air, thy virtuous daughter,
|
||||
Which we call 'mollis aer,' and 'mollis aer'
|
||||
We term it 'mulier'; which 'mulier' I divine
|
||||
Is this most constant wife, who even now
|
||||
Answering the letter of the oracle,
|
||||
Unknown to you, unsought, were clipp'd about
|
||||
With this most tender air.
|
||||
CYMBELINE. This hath some seeming.
|
||||
SOOTHSAYER. The lofty cedar, royal Cymbeline,
|
||||
Personates thee; and thy lopp'd branches point
|
||||
Thy two sons forth, who, by Belarius stol'n,
|
||||
For many years thought dead, are now reviv'd,
|
||||
To the majestic cedar join'd, whose issue
|
||||
Promises Britain peace and plenty.
|
||||
CYMBELINE. Well,
|
||||
My peace we will begin. And, Caius Lucius,
|
||||
Although the victor, we submit to Caesar
|
||||
And to the Roman empire, promising
|
||||
To pay our wonted tribute, from the which
|
||||
We were dissuaded by our wicked queen,
|
||||
Whom heavens in justice, both on her and hers,
|
||||
Have laid most heavy hand.
|
||||
SOOTHSAYER. The fingers of the pow'rs above do tune
|
||||
The harmony of this peace. The vision
|
||||
Which I made known to Lucius ere the stroke
|
||||
Of yet this scarce-cold battle, at this instant
|
||||
Is full accomplish'd; for the Roman eagle,
|
||||
From south to west on wing soaring aloft,
|
||||
Lessen'd herself and in the beams o' th' sun
|
||||
So vanish'd; which foreshow'd our princely eagle,
|
||||
Th'imperial Caesar, Caesar, should again unite
|
||||
His favour with the radiant Cymbeline,
|
||||
Which shines here in the west.
|
||||
CYMBELINE. Laud we the gods;
|
||||
And let our crooked smokes climb to their nostrils
|
||||
From our bless'd altars. Publish we this peace
|
||||
To all our subjects. Set we forward; let
|
||||
A Roman and a British ensign wave
|
||||
Friendly together. So through Lud's Town march;
|
||||
And in the temple of great Jupiter
|
||||
Our peace we'll ratify; seal it with feasts.
|
||||
Set on there! Never was a war did cease,
|
||||
Ere bloody hands were wash'd, with such a peace.
|
67
tepechin_kirill_lab_7/lab7.py
Normal file
@ -0,0 +1,67 @@
|
||||
import numpy as np
|
||||
from keras.models import Sequential
|
||||
from keras.layers import Embedding, LSTM, Dense
|
||||
from keras.preprocessing.text import Tokenizer
|
||||
from keras.preprocessing.sequence import pad_sequences
|
||||
from keras.src.layers import Dropout
|
||||
|
||||
#filename = "rutext.txt"
|
||||
filename = "engtext.txt"
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
|
||||
# Создаем токенизатор и преобразуем текст в последовательности
|
||||
tokenizer = Tokenizer()
|
||||
tokenizer.fit_on_texts([text])
|
||||
total_words = len(tokenizer.word_index) + 1
|
||||
|
||||
input_sequences = []
|
||||
for line in text.split('\n'):
|
||||
token_list = tokenizer.texts_to_sequences([line])[0]
|
||||
for i in range(1, len(token_list)):
|
||||
n_gram_sequence = token_list[:i + 1]
|
||||
input_sequences.append(n_gram_sequence)
|
||||
|
||||
# Подготавливаем данные для обучения
|
||||
max_sequence_length = max([len(x) for x in input_sequences])
|
||||
input_sequences = pad_sequences(input_sequences, maxlen=max_sequence_length, padding='pre')
|
||||
X, y = input_sequences[:, :-1], input_sequences[:, -1]
|
||||
|
||||
# Определяем архитектуру нейронной сети
|
||||
model = Sequential()
|
||||
model.add(Embedding(total_words, 50, input_length=max_sequence_length - 1))
|
||||
model.add(LSTM(512))
|
||||
model.add(Dropout(0.2))
|
||||
model.add(Dense(total_words, activation='softmax'))
|
||||
|
||||
|
||||
# Компилируем модель
|
||||
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
|
||||
|
||||
# Обучаем модель
|
||||
model.fit(X, y, epochs=50, verbose=1)
|
||||
|
||||
|
||||
# Функция для генерации текста
|
||||
def generate_text(seed_text, next_words, max_sequence_len, model, tokenizer):
|
||||
for _ in range(next_words):
|
||||
token_list = tokenizer.texts_to_sequences([seed_text])[0]
|
||||
token_list = pad_sequences([token_list], maxlen=max_sequence_len - 1, padding='pre')
|
||||
predicted_probs = model.predict(token_list)[0]
|
||||
|
||||
predicted = np.random.choice(len(predicted_probs), p=predicted_probs)
|
||||
|
||||
output_word = ""
|
||||
for word, index in tokenizer.word_index.items():
|
||||
if index == predicted:
|
||||
output_word = word
|
||||
break
|
||||
seed_text += " " + output_word
|
||||
return seed_text
|
||||
|
||||
|
||||
# Пример использования
|
||||
#generated_text = generate_text("Война и", 25, max_sequence_length, model, tokenizer)
|
||||
generated_text = generate_text("Shakespeare was", 25, max_sequence_length, model, tokenizer)
|
||||
|
||||
print(generated_text)
|
40
tepechin_kirill_lab_7/rutext.txt
Normal file
@ -0,0 +1,40 @@
|
||||
На выходе император Франц только пристально вгляделся в лицо князя Андрея, стоявшего в назначенном месте между австрийскими офицерами, и кивнул ему своей длинной головой. Но после выхода вчерашний флигель-адъютант с учтивостью передал Болконскому желание императора дать ему аудиенцию. Император Франц принял его, стоя посредине комнаты. Перед тем как начинать разговор, князя Андрея поразило то, что император как будто смешался, не зная, что сказать, и покраснел.
|
||||
|
||||
– Скажите, когда началось сражение? – спросил он поспешно.
|
||||
|
||||
Князь Андрей отвечал. После этого вопроса следовали другие, столь же простые вопросы: «Здоров ли Кутузов? как давно выехал он из Кремса?» и т. п. Император говорил с таким выражением, как будто вся цель его состояла только в том, чтобы сделать известное количество вопросов. Ответы же на эти вопросы, как было слишком очевидно, не могли интересовать его.
|
||||
|
||||
– В котором часу началось сражение? – спросил император.
|
||||
|
||||
– Не могу донести вашему величеству, в котором часу началось сражение с фронта, но в Дюренштейне, где я находился, войско начало атаку в шестом часу вечера, – сказал Болконский, оживляясь и при этом случае предполагая, что ему удастся представить уже готовое в его голове правдивое описание всего того, что он знал и видел.
|
||||
|
||||
Но император улыбнулся и перебил его:
|
||||
|
||||
– Сколько миль?
|
||||
|
||||
– Откуда и докуда, ваше величество?
|
||||
|
||||
– От Дюренштейна до Кремса.
|
||||
|
||||
– Три с половиною мили, ваше величество.
|
||||
|
||||
– Французы оставили левый берег?
|
||||
|
||||
– Как доносили лазутчики, в ночь на плотах переправились последние.
|
||||
|
||||
– Достаточно ли фуража в Кремсе?
|
||||
|
||||
– Фураж не был доставлен в том количестве…
|
||||
|
||||
Император перебил его:
|
||||
|
||||
– В котором часу убит генерал Шмит?
|
||||
|
||||
– В семь часов, кажется.
|
||||
|
||||
– В семь часов? Очень печально! Очень печально!
|
||||
|
||||
Император сказал, что он благодарит, и поклонился. Князь Андрей вышел и тотчас же со всех сторон был окружен придворными. Со всех сторон глядели на него ласковые глаза и слышались ласковые слова. Вчерашний флигель-адъютант делал ему упреки, зачем он не остановился во дворце, и предлагал ему свой дом. Военный министр подошел, поздравляя его с орденом Марии Терезии 3-й степени, которым жаловал его император. Камергер императрицы приглашал его к ее величеству. Эрцгерцогиня тоже желала его видеть. Он не знал, кому отвечать, и несколько секунд собирался с мыслями. Русский посланник взял его за плечо, отвел к окну и стал говорить с ним.
|
||||
|
||||
Вопреки словам Билибина, известие, привезенное им, было принято радостно. Назначено было благодарственное молебствие. Кутузов был награжден Марией Терезией большого креста, и вся армия получила награды. Болконский получал приглашения со всех сторон и все утро должен был делать визиты главным сановникам Австрии. Окончив свои визиты в пятом часу вечера, мысленно сочиняя письмо отцу о сражении и о своей поездке в Брюнн, князь Андрей возвращался домой к Билибину. Прежде чем ехать к Билибину, князь Андрей поехал в книжную лавку запастись на поход книгами и засиделся в лавке. У крыльца дома, занимаемого Билибиным, стояла до половины уложенная вещами бричка, и Франц, слуга Билибина, с трудом таща чемодан, вышел из двери.
|
||||
|
BIN
tepechin_kirill_lab_7/test1.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
tepechin_kirill_lab_7/test1_text.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
tepechin_kirill_lab_7/test2.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
tepechin_kirill_lab_7/test2_text.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
tepechin_kirill_lab_7/test3.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
tepechin_kirill_lab_7/test3_text.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
tepechin_kirill_lab_7/test4.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
tepechin_kirill_lab_7/test4_text.png
Normal file
After Width: | Height: | Size: 6.7 KiB |