七夕节,程序员们都怎么哄女朋友开心?
大家好,馬上就七夕節了,七夕節是牛郎織女鵲橋相會的相會的日子。
這篇文章的前提是,你得有個女朋友,沒有就先收藏著吧!
一、七夕節的由來
七夕節的來源是梁山伯與祝英臺的美麗傳說,化成了一對蝴蝶~
美麗的神話!雖然現在一般是過214的情人節了,但是不得不說,古老的傳統的文化遺產,還是要繼承啊~
在互聯網公司中,主要的程序員品種包括:前端工程師,后端工程師,算法工程師。(客戶端表示有被冒犯到)
二、程序員的分類
對于具體的職業職能劃分還不是很清楚的,我們簡單的介紹一下不同程序員崗位的職責:
前端程序員:繪制UI界面,與設計和產品經理進行需求的對接,繪制特定的前端界面推向用戶
后端程序員:接收前端json字符串,與數據庫對接,將json推向前端進行顯示
算法工程師:進行特定的規則映射,優化函數的算法模型,改進提高映射準確率。
七夕節到了,怎么結合自身的的專業技能,哄女朋友開心呢?
三、是時候表演真正的技術了!
前端工程師:我先來,畫個動態的晚霞頁面!
1.定義樣式風格:
.star?{width: 2px;height: 2px;background: #f7f7b6;position: absolute;left: 0;top: 0;backface-visibility: hidden; }2.定義動畫特性:
@keyframes?rotate {0% {transform: perspective(400px) rotateZ(20deg) rotateX(-40deg) rotateY(0);}100% {transform: perspective(400px) rotateZ(20deg) rotateX(-40deg) rotateY(-360deg);} }3.定義星空樣式數據
export?default?{data() {return?{starsCount: 800, //星星數量distance: 900, //間距}} }4.定義星星運行速度與規則:
starNodes.forEach((item) =>?{let?speed = 0.2?+ Math.random() * 1;let?thisDistance = this.distance + Math.random() * 300;item.style.transformOrigin = `0 0 ${thisDistance}px`;item.style.transform =`translate3d(0,0,-${thisDistance}px)rotateY(${Math.random() * 360}deg)rotateX(${Math.random() * -50}deg)scale(${speed},${speed})`;});前端預覽效果圖:
后端工程師看后,先點了點頭,然后表示不服,畫頁面有點膚淺了,我開發一個接口,定時在女朋友生日的時候發送祝福郵件吧!
1.導入pom.xml 文件
<!-- mail郵件服務啟動器 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency>2.application-dev.properties內部增加配置鏈接
#QQ\u90AE\u7BB1\u90AE\u4EF6\u53D1\u9001\u670D\u52A1\u914D\u7F6E spring.mail.host=smtp.qq.com spring.mail.port=587## qq郵箱 spring.mail.username=#yourname#@qq.com ## 這里填郵箱的授權碼 spring.mail.password=#yourpassword#3.配置郵件發送工具類
MailUtils.java
@Component public?class?MailUtils {@Autowiredprivate?JavaMailSenderImpl mailSender;@Value("${spring.mail.username}")private?String?mailfrom;// 發送簡單郵件public?void?sendSimpleEmail(String?mailto, String?title, String?content) {// 定制郵件發送內容SimpleMailMessage message = new?SimpleMailMessage();message.setFrom(mailfrom);message.setTo(mailto);message.setSubject(title);message.setText(content);// 發送郵件mailSender.send(message);} }4.測試使用定時注解進行注釋
@Component class?DemoApplicationTests?{@Autowiredprivate?MailUtils mailUtils;/*** 定時郵件發送任務,每月1日中午12點整發送郵件*/@Scheduled(cron = "0 0 12 1 * ?")void?sendmail(){// 定制郵件內容StringBuffer content = new?StringBuffer();content.append("HelloWorld");//分別是接收者郵箱,標題,內容mailUtils.sendSimpleEmail("123456789@qq.com","自定義標題",content.toString());} }@scheduled注解 使用方法:cron:秒,分,時,天,月,年,* 號表示 所有的時間均匹配
5. 工程進行打包,部署在服務器的容器中運行即可。
算法工程師,又開發接口,又畫頁面,我就訓練一個自動寫詩機器人把!
1.定義神經網絡RNN結構
def neural_network(model = 'gru', rnn_size = 128, num_layers = 2):cell = tf.contrib.rnn.BasicRNNCell(rnn_size, state_is_tuple = True)cell = tf.contrib.rnn.MultiRNNCell([cell] * num_layers, state_is_tuple = True)initial_state = cell.zero_state(batch_size, tf.float32)with tf.variable_scope('rnnlm'):softmax_w = tf.get_variable("softmax_w", [rnn_size, len(words)])softmax_b = tf.get_variable("softmax_b", [len(words)])embedding = tf.get_variable("embedding", [len(words), rnn_size])inputs = tf.nn.embedding_lookup(embedding, input_data)outputs, last_state = tf.nn.dynamic_rnn(cell, inputs, initial_state = initial_state, scope = 'rnnlm')output = tf.reshape(outputs, [-1, rnn_size])logits = tf.matmul(output, softmax_w) + softmax_bprobs = tf.nn.softmax(logits)return?logits, last_state, probs, cell, initial_state2.定義模型訓練方法
def train_neural_network():logits, last_state, _, _, _ = neural_network()targets = tf.reshape(output_targets, [-1])loss = tf.contrib.legacy_seq2seq.sequence_loss_by_example([logits], [targets], \[tf.ones_like(targets, dtype = tf.float32)], len(words))cost = tf.reduce_mean(loss)learning_rate = tf.Variable(0.0, trainable = False)tvars = tf.trainable_variables()grads, _ = tf.clip_by_global_norm(tf.gradients(cost, tvars), 5)#optimizer = tf.train.GradientDescentOptimizer(learning_rate)optimizer = tf.train.AdamOptimizer(learning_rate)train_op = optimizer.apply_gradients(zip(grads, tvars))Session_config = tf.ConfigProto(allow_soft_placement = True)Session_config.gpu_options.allow_growth = Truetrainds = DataSet(len(poetrys_vector))with tf.Session(config = Session_config) as?sess:sess.run(tf.global_variables_initializer())saver = tf.train.Saver(tf.global_variables())last_epoch = load_model(sess, saver, 'model/')for?epoch in range(last_epoch + 1, 100):sess.run(tf.assign(learning_rate, 0.002?* (0.97?** epoch)))#sess.run(tf.assign(learning_rate, 0.01))all_loss = 0.0for?batche in range(n_chunk):x,y?= trainds.next_batch(batch_size)train_loss, _, _ = sess.run([cost, last_state, train_op], feed_dict={input_data:?x, output_targets:?y})all_loss = all_loss + train_lossif?batche % 50?== 1:print(epoch, batche, 0.002?* (0.97?** epoch),train_loss)saver.save(sess, 'model/poetry.module', global_step = epoch)print?(epoch,' Loss: ', all_loss * 1.0?/ n_chunk)3.數據集預處理
poetry_file ='data/poetry.txt' # 詩集 poetrys = [] with?open(poetry_file, "r", encoding = 'utf-8') as?f:for?line in?f:try:#line = line.decode('UTF-8')line = line.strip(u'\n')title, content = line.strip(u' ').split(u':')content = content.replace(u' ',u'')if?u'_'?in?content or?u'('?in?content or?u'('?in?content or?u'《'?in?content or?u'['?in?content:continueif?len(content) < 5?or?len(content) > 79:continuecontent = u'['?+ content + u']'poetrys.append(content)except?Exception as?e:passpoetry.txt文件中存放這唐詩的數據集,用來訓練模型
4.測試一下訓練后的模型效果:
藏頭詩創作:“七夕快樂”
模型運算的結果:
哈哈哈,各種節日都是程序員的表(zhuang)演(bi) 時間,不過這些都是錦上添花,只有實實在在,真心才會天長地久啊~
提前祝各位情侶七夕節快樂!
我是千與千尋,我們下期見~
end
往期精彩回顧適合初學者入門人工智能的路線及資料下載機器學習及深度學習筆記等資料打印機器學習在線手冊深度學習筆記專輯《統計學習方法》的代碼復現專輯 AI基礎下載機器學習的數學基礎專輯黃海廣老師《機器學習課程》課件合集 本站qq群851320808,加入微信群請掃碼:總結
以上是生活随笔為你收集整理的七夕节,程序员们都怎么哄女朋友开心?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 360浏览器一打开就是瑞星安全网址怎么办
- 下一篇: 腾讯视频下载安装免费装到手机_腾讯视频怎