White Essay

       The weather today is neither good nor bad, wet morning on the way, starting with the funny little later than brothers, stepping on a bicycle on the road ........

       The first idea to open a computer is running a linear regression program on yesterday packed tensorflow, first encountered the problem is that, since it is linear , I would like to see its scatter before the image, it has been thought of by of

matplotlib. so sick day begins ......

         First of all, I installed the python interpreter has three, the first is been used (installed in C drive, matplotlib always available), is second in the D drive Anaconda in the ( newly installed, not used), third It is in

Anaconda / the env Python interpreter tensorflow the next file. 

       I then operation proceeds toggle interpreter pycharm also utilized pip3 install -t path specified packet (e.g., D: \ Anaconda \ envs \ tensorflow \ Lib \ site-packages) matplotlib = version, the junction

If the C disk matplotlib are engaged in the collapse, no matter how change will not produce anything .....

      Pm, among reptiles watching video depressed, just to see which part scrapy mounted, as shown in the following steps:

# Windows platform 
    1, PIP3 install wheel # After installation, the software will support the installation file through wheel, wheel file official website: HTTPS: //www.lfd.uci.edu/~gohlke/pythonlibs 
    2 , PIP3 install lxml
     3, PIP3 install pyopenssl   # pyopenssl is a python module encapsulates openssl. It can be easily performed using a number of encryption and decryption operations. 
    # Pywin32 and python3 have incompatibility issues, install the download is compatible with the current python version, use pip install path name (.wheel) papers 
    4, download and install pywin32: https: //sourceforge.net/projects/ pywin32 / Files / pywin32 /   # to 220 directory for your system and python interpreter download the appropriate version 
    # using domestic sources download directly 
    pip3 --no-cache-dir install -i https://mirrors.aliyun.com/ pypi / the Simple / pypiwin32 --ignore- Installed
     # because scrapy is based on twisted develop, so you need to download twisted
    5, download twisted the wheel file: HTTP: //www.lfd.uci.edu/~gohlke/pythonlibs/ # twisted   
    6, execution pip3 install the download directory \ Twisted-17.9.0-CP36-cp36m-win_amd64.whl    # installation local twisted file 
   # cmd: >> PIP3 install D: \ tank_files \ Twisted-18.9.0-CP36-cp36m-win_amd64.whl 
    7, PIP3 install scrapy   # the 1-6 finish later download scarpy frame, otherwise it will error
  
# Linux platform 
    1, pip3 install scrapy

          I see pip3 big head, bite the bullet and look scrapy to install it, the result is a bunch of dependence, version error. It is not, follow the steps knock directly in cmd, look for the package, find the file, and then install the default my path is

In the C disk python library (step 4 can be ignored, Step 6 My computer is selected Twisted-17.9.0-cp36-cp36m- win_amd32.whl), all the way to trip over, the results of the installation was successful!

         This time I thought of the matplotlib, so the Internet to find a more stable version 2.0.2, the installation is successful on cmd (change many times before they succeed!) This time was a little prospect of a solution, adding immediately with path

Tensorflow method to add this rare version, the result is gains across the board, sank a length, this time can only be tensorflow mt version is not compatible with the problem, so we supposed to do?

        Since I can not find you, then you help yourself:

  Ultimately, it found a 3.0.3 version:

   ! Well, today's story to which it out a day, below the chart put:

code show as below:

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt

num_point = 1000
v_set = []
for i in range(num_point):
    X1 = np.random.normal (0.0,0.55 )
 # we often use np.random.randn (size) so-called standard normal distribution ([mu] = 0, [sigma] =. 1), 
# corresponding to np.random.normal ( = 0 LOC, Scale =. 1, size) 
    Y1 = X1 * 0.2 +0.5 + np.random.normal (0.0,0.05 )
    v_set.append([x1,y1])
x_data = [v[0] for v in v_set]
y_data = [v[1] for v in v_set]

W = tf.Variable(tf.random.uniform([1],-1.0,1.0),name='W')
b = tf.Variable(tf.zeros([1]),name='b')


plt.scatter(x_data,y_data,c='r')
plt.show()
y = W * x_data +b
#均方差作为损失
loss = tf.reduce_mean (tf.square(y - y_data),name='loss')
# 学习率为0.6
optimizer=tf.train.GradientDescentOptimizer(0.6)
#优化训练
train= optimizer.minimize(loss,name='train')
sess = tf.Session()
init = tf.global_variables_initializer()
sess.run(init)
print('W=',sess.run(W),'b=',sess.run(b),"loss =",sess.run(loss))

for step  in range(200):
    sess.run(train)
    print("W=",sess.run(W),'b=',sess.run(b),"loss=",sess.run(loss))

       晚安!

 

Guess you like

Origin www.cnblogs.com/sima-3/p/11099771.html