from docx import Document
from docx.shared import Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
doc = Document()
tables = doc.add_table(rows=3, cols=2)
tables.alignment = WD_TABLE_ALIGNMENT.CENTER
count = 0
for i in range(3):
for j in range(2):
count += 1
fname = str(count) + '.jpg'
s = '風景' + str(count)
p = doc.tables[0].rows[i].cells[j].paragraphs[0]
p.alignment=WD_ALIGN_PARAGRAPH.CENTER
r = p.add_run()
r.add_picture(fname,width=Cm(8.0), height=Cm(6.0))
r.add_break()
r.add_text(s)
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r = p.add_run()
r.add_text('6つの風景')
doc.save('test.docx')
import tensorflow as tf
import numpy as np
x_data = np.loadtxt('exam-result.csv', delimiter=',', usecols=[3], skiprows=1)
y_data = np.loadtxt('exam-result.csv', delimiter=',', usecols=[1], skiprows=1)
# Try to find values for W and b that compute y_data = W * x_data + b
# (We know that W should be 0.1 and b 0.3, but TensorFlow will
# figure that out for us.)
W = tf.Variable(tf.zeros([1]))
b = tf.Variable(tf.zeros([1]))
y = W * x_data + b
# Minimize the mean squared errors.
loss = tf.reduce_mean(tf.square(y - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)
# Before starting, initialize the variables. We will 'run' this first.
init = tf.global_variables_initializer()
# Launch the graph.
sess = tf.Session()
sess.run(init)
# Fit the line.
for step in range(2001):
sess.run(train)
if step % 200 == 0:
print(step, sess.run(W), sess.run(b))
# Close the Session when we're done.
sess.close()