ÔÚLinuxϵͳÉÏʹÓÃPyCharm¾ÙÐÐÉî¶ÈѧϰµÄÉèÖÃÒªÁì
ÔÚlinuxϵͳÉÏʹÓÃpycharm¾ÙÐÐÉî¶ÈѧϰµÄÉèÖÃÒªÁì
Éî¶ÈѧϰÊÇÈ˹¤ÖÇÄÜÁìÓòµÄÒ»¸öÈÈÃÅÆ«Ïò£¬Ðí¶àÑо¿Ö°Ô±ºÍ¿ª·¢Õ߶¼ÔÚʹÓÃÉî¶ÈѧϰËã·¨½â¾öÖÖÖÖÎÊÌâ¡£¶øPython×÷ΪһÖÖÆÕ±éʹÓõıà³ÌÓïÑÔ£¬ÓµÓÐÐí¶àÓÅÒìµÄÉî¶Èѧϰ¿ò¼Ü£¬ÈçTensorFlow¡¢PyTorchºÍKerasµÈ¡£¶øPyCharm×÷Ϊһ¿îÇ¿Ê¢µÄPython¿ª·¢ÇéÐΣ¬ÌṩÁ˸»ºñµÄ¹¦Ð§ºÍ²å¼þ£¬ºÜÊÇÊʺϾÙÐÐÉî¶ÈѧϰµÄ¿ª·¢ÊÂÇé¡£±¾ÎĽ«ÏÈÈÝÔÚlinuxϵͳÉÏʹÓÃpycharm¾ÙÐÐÉî¶ÈѧϰµÄÉèÖÃÒªÁ죬²¢¸½´øһЩ´úÂëʾÀý¡£
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖò¢ÉèÖÃPyCharm¡£¿ÉÒÔ´ÓJetBrains¹Ù·½ÍøÕ¾ÏÂÔØPyCharmµÄLinux°æ±¾×°Öðü¡£ÏÂÔØÍê³Éºó£¬ÔÚÖÕ¶ËÖÐÖ´ÐÐÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº
sudo tar -xzf pycharm-*.tar.gz -C /opt/ sudo ln -s /opt/pycharm-*/bin/pycharm.sh /usr/local/bin/pycharm
µÇ¼ºó¸´ÖÆ
È»ºó£¬ÎÒÃÇÐèҪװÖÃPython¡£´ó²¿·ÖÉî¶Èѧϰ¿ò¼Ü¶¼Ö§³ÖPython 3.x°æ±¾£¬Òò´ËÎÒÃÇ¿ÉÒÔÑ¡Ôñ×°ÖÃPython 3.x¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃPython£º
sudo apt-get update sudo apt-get install python3
µÇ¼ºó¸´ÖÆ
½ÓÏÂÀ´£¬ÎÒÃÇÐèҪװÖÃÉî¶Èѧϰ¿ò¼Ü¡£ÒÔTensorFlowΪÀý£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃTensorFlow£º
pip install tensorflow
µÇ¼ºó¸´ÖÆ
ÈôÊÇÐèҪʹÓÃGPU¼ÓËÙ£¬»¹ÐèҪװÖÃCUDAºÍcuDNN¡£¿ÉÒԲο¼TensorFlow¹Ù·½Îĵµ¾ÙÐÐ×°ÖúÍÉèÖá£
Íê³ÉÒÔÉÏ°ì·¨ºó£¬ÎÒÃÇ¿ÉÒÔ·¿ªPyCharm²¢½¨ÉèÒ»¸öÐÂÏîÄ¿¡£ÔÚ½¨ÉèÏîÄ¿Àú³ÌÖУ¬Ñ¡ÔñPythonÚ¹ÊÍÆ÷ΪÎÒÃÇ×°ÖõÄPython 3.x°æ±¾¡£
½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÔÚPyCharmÖÐ×°ÖÃÉî¶Èѧϰ¿ò¼ÜµÄ²å¼þ¡£Ñ¡Ôñ”File” -> “Settings” -> “Plugins”£¬ÔÚËÑË÷¿òÖÐÊäÈë”TensorFlow Integration”²¢×°Öøòå¼þ¡£×°ÖÃÍê³Éºó£¬ÖØÆôPyCharm¡£
ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔµ¼ÈëÉî¶Èѧϰ¿ò¼Ü²¢×îÏȱàд´úÂëÁË¡£ÏÂÃæÒÔTensorFlowΪÀý£¬ÑÝʾһ¸ö¼òÆÓµÄÉñ¾ÍøÂçÄ£×ӵĹ¹½¨ºÍѵÁ·Àú³Ì¡£
import tensorflow as tf # ¼ÓÔØÊý¾Ý¼¯ mnist = tf.keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() # Êý¾ÝÔ¤´¦Öóͷ£ x_train, x_test = x_train / 255.0, x_test / 255.0 # ¹¹½¨Ä£×Ó model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation='softmax') ]) # ±àÒëÄ£×Ó model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) # ѵÁ·Ä£×Ó model.fit(x_train, y_train, epochs=5) # ÆÀ¹ÀÄ£×Ó model.evaluate(x_test, y_test)
µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂëÑÝʾÁËʹÓÃTensorFlow¹¹½¨Ò»¸ö¼òÆÓµÄÉñ¾ÍøÂçÄ£×Ó£¬²¢¶ÔMNISTÊÖдÊý×ÖÊý¾Ý¼¯¾ÙÐÐѵÁ·ºÍÆÀ¹ÀµÄÀú³Ì¡£
ͨ¹ýÒÔÉÏ°ì·¨£¬ÎÒÃÇÀֳɵØÔÚLinuxϵͳÉÏÉèÖÃÁËPyCharm£¬²¢Ê¹ÓÃTensorFlow¾ÙÐÐÁËÉî¶ÈѧϰµÄ¿ª·¢ÊÂÇé¡£ËäÈ»£¬PyCharmÒ²Ö§³ÖÆäËûÉî¶Èѧϰ¿ò¼Ü£¬ºÃ±ÈPyTorchºÍKerasµÈ£¬Ö»ÐèҪƾ֤ÏìÓ¦µÄÎĵµ¾ÙÐÐÉèÖü´¿É¡£Ï£Íû±¾ÎĶÔÏ£ÍûÔÚLinuxϵͳÉϾÙÐÐÉî¶Èѧϰ¿ª·¢µÄ¶ÁÕßÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔÚLinuxϵͳÉÏʹÓÃPyCharm¾ÙÐÐÉî¶ÈѧϰµÄÉèÖÃÒªÁìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡