## https://machinelearningmastery.com/display-deep-learning-model-training-history-in-keras/

# Visualize training history
from keras.models import Sequential
from keras.layers import Dense
import matplotlib.pyplot as plt
import numpy
import requests
import csv
import urllib.request
import pandas as pd

## https://stackoverflow.com/a/36162600/3806250
## https://stackoverflow.com/a/18897408/3806250
url = 'https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv'
response = requests.get(url)
response.iter_lines()
text = response.iter_lines()
# reader = csv.reader(text, delimiter = ',')
reader = numpy.loadtxt(text, delimiter = ',')
# data = [row for row in reader]

# load pima indians dataset
dataset = reader
pd.DataFrame(dataset)

# split into input (X) and output (Y) variables
X = dataset[:,0:8]
Y = dataset[:,8]

# create model
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))

# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

# Fit the model
history = model.fit(X, Y, validation_split=0.33, epochs=150, batch_size=10, verbose=0)

# list all data in history
print(history.history.keys())

# summarize history for accuracy
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
plt.title('model accuracy')
plt.ylabel('accuracy')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()

# summarize history for loss
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('model loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'test'], loc='upper left')
plt.show()

连接来源:Display Deep Learning Model Training History in Keras

这python路径像天上的星星✨太多不统一,使用个tensorflowkeras都折腾了我,晕!

  • ~/bin/python
  • ~/bin/python2
  • ~/bin/python2.71
  • ~/bin/python3
  • /bin/python3.8
  • ~/bin/python3.85
  • /usr/bin/python2
  • /usr/bin/python2.71
  • /usr/bin/python3
  • /usr/bin/python3.8
  • /usr/bin/python3.85
  • ~/anaconda3/bin/python
  • ~/anaconda3/bin/python3
  • ~/anaconda3/bin/python3.8
  • ~/miniconda/bin/python
  • ~/miniconda/bin/python3
    ...

systemctl reboot --firmware-setup重新安装Linux,请高手指点一下...

刚搜索了下tasksel,才知道高颜值叫Kubuntu,先安装后再忙Coursera

只用 conda 装 Python 和 Python 包就好了,反正在 HOME 目录,随便装随便卸载。装在 /usr/bin/ 这种系统目录就很危险,哪天把系统依赖的 Python 卸载系统就完蛋了。

    CyrusYip 对呀,anaconda通过conda创建一个环境,然后在环境内安装包。或者也可以通过virtualenv管理。

    • ryo 回复了此帖

      CyrusYip
      那天卸装python2*后还安然无恙,然后再卸装python3*就当机了,原来Linux系统内嵌python语言... 目前在摸索着 jupyter, RStudio使用tensorflowkeras...

      正在修读两个课程当中 :

        CMCai0104

        学习中,原来python尽量别用sudo,然后摸索了下,sudo apt install conda安装了后建了个虚拟环境,然后conda activate

        ## https://stackoverflow.com/a/58553001/3806250
        
        ## https://docs.rstudio.com/how-to-guides/rsc/publish-jupyter-notebook
        jupyter-nbextension install --sys-prefix --py rsconnect_jupyter
        jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter
        jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter
        
        ## https://github.com/ipython/ipyparallel
        jupyter nbextension install --sys-prefix --py ipyparallel
        jupyter nbextension enable --sys-prefix --py ipyparallel
        jupyter serverextension enable --sys-prefix --py ipyparallel

        后再conda deactivate

        晨曦了,要睡觉了... 睡醒后再研究下tensorflowkeras... zzz

          ryo 所以说不要删除系统自带的包。也不推荐源码安装 Python,有可能覆盖掉系统自带的 Python,而且直接装在系统目录真的很难管理。

          ryo 我之前写的这篇文章或许对你有帮助:轻松安装 Python 和 Python 包

          • ryo 觉得很赞

          ryo

          新版的都是node而非node.js,导致一直出现错误信息... 刚刚才发现

          For JupyterLab <3, you may also need to ensure nodejs is installed, and rebuild the application

          source : jupyter-widgets/pythreejs

          ~$ jupyter-lab --version
          3.0.15
          • ryo 回复了此帖

            参考了

            To do this, set the R_LIBS_USER environment variable. To preserve it across shell sessions, set the value in ~/.profile or similar


            ~$ sudo R --slave -e 'quit("no", IRkernel::installspec(FALSE))'
            [sudo] password for englianhu: 
            [InstallKernelSpec] Installed kernelspec ir in /usr/local/share/jupyter/kernels/ir)

            安装R程序包没权限问题了。

            ryo ryo
            还是停留在这个步骤,JupyterLab >=3怎么安装激活Publish呢?

            jupyter-nbextension install --sys-prefix --py rsconnect_jupyter
            jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter
            jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter


            参考文献:

            Create an Ubuntu 20.04 Docker image with PyTorch & TensorFlow support

            # Build a Docker image for Ubuntu 20.04 (focal). You can substitute focal for bionic or xenial to change the ubuntu version.
            sudo docker build -t lambda-stack:20.04 -f Dockerfile.focal git://github.com/lambdal/lambda-stack-dockerfiles.git

            原文:Lambda Stack is all the AI software you need,
            and it's always up to date

            这儿有篇docker相关文章,写大略阅读下...

            17 天 后

            CMCai0104

            :~$ wget https://cran.r-project.org/src/contrib/tensorflow_2.4.0.tar.gz
            :~$ R CMD INSTALL tensorflow_2.4.0.tar.gz
            ...
            ...
            *** installing help indices
            ** building package indices
            ** testing if installed package can be loaded from temporary location
            ** testing if installed package can be loaded from final location
            ** testing if installed package keeps a record of temporary installation path
            * DONE (tensorflow)
            ✓ [master]> library(tensorflow)
            ✓ [master]> library(reticulate)
            ✓ [master]> tf$constant("Hellow Tensorflow")
            Error: Python module tensorflow was not found.
            
            Detected Python configuration:
            
            python:         /home/englianhu/anaconda3/bin/python3
            libpython:      /home/englianhu/anaconda3/lib/libpython3.8.so
            pythonhome:     /home/englianhu/anaconda3:/home/englianhu/anaconda3
            version:        3.8.8 (default, Apr 13 2021, 19:58:26)  [GCC 7.3.0]
            numpy:          /home/englianhu/.local/lib/python3.8/site-packages/numpy
            numpy_version:  1.19.5
            tensorflow:     /home/englianhu/.local/lib/python3.8/site-packages/tensorflow
            
            NOTE: Python version was forced by RETICULATE_PYTHON

            原文 : https://github.com/rstudio/tensorflow/issues/466#issuecomment-855280587