搜索

pdf文档 Notes for install Keras on Anaconda3

654.13 KB 3 页 0 下载 78 浏览 0 评论 0 收藏
语言 格式 评分
英语
.pdf
3
摘要
文档提供了在Anaconda3环境中安装Keras和Tensorflow的指导。针对2012年及以后购买的PC,文档介绍了安装步骤,包括使用终端命令安装必要的包,并通过MNIST数据集测试安装是否成功。文档还提到,对于2012年前的CPU,需要使用Tensorflow 1.5或更早版本以避免AVX指令集不兼容的问题。
AI总结
## 安装 Keras 的注意事项与步骤总结 ### 1. 硬件要求 - 如果你的 CPU 购买时间早于 2012 年,无法运行 1.6 版本及以后的 TensorFlow,因为需要 AVX 指令集支持。请确保你的设备满足要求。 ### 2. 安装步骤 #### Step 1: 安装 Anaconda3 和 RStudio - 遵循官方文档或视频教程完成安装: - [员工指南](https://web.microsoftstream.com/video/6c1dea0f-a672-4f67-8983-ea5219200cee) - [学生指南](https://web.microsoftstream.com/video/33db8bdd-dd29-4c75-8cf9-4eaa0ac4dc08) #### Step 2: 安装依赖包 在 Anaconda3 提示符中依次运行以下命令(以环境 `rstudio` 为例): 1. 安装 Python 3.6: ```bash conda install python=3.6 ``` 2. 安装 TensorFlow: ```bash conda install -c conda-forge tensorflow ``` 3. 安装 R 的 TensorFlow 包: ```bash conda install -c r r-tensorflow ``` 4. 安装 Keras: ```bash conda install -c conda-forge r-keras ``` #### Step 3: 验证安装 在 RStudio 中运行以下代码检查安装是否成功: ```R library(keras) mnist <- dataset_mnist() # 数据预处理 train_images <- array_reshape(mnist$train$x, c(nrow(mnist$train$x), 28*28)) / 255 test_images <- array_reshape(mnist$test$x, c(nrow(mnist$test$x), 28*28)) / 255 train_labels <- to_categorical(mnist$train$y, 10) test_labels <- to_categorical(mnist$test$y, 10) # 模型定义 model <- keras_model_sequential() %>% layer_dense(units = 256, activation = 'relu', input_shape = c(28*28)) %>% layer_dense(units = 128, activation = 'relu') %>% layer_dense(units = 10, activation = 'softmax') # 编译与训练 model %>% compile( loss = 'categorical_crossentropy', optimizer = optimizer_rmsprop(), metrics = c('accuracy') ) model %>% fit( train_images, train_labels, epochs = 30, batch_size = 128 ) ``` ### 3. 预期结果 - 训练过程中会显示每轮的准确率和损失值,最终应输出训练完成的信息。 通过以上步骤,可以顺利完成 Keras 的安装与验证。
P1
P2
P3
下载文档到本地,方便使用
文档评分
请文明评论,理性发言.