Neural Networks and Deep Learning第二周作业 python Basics with numpy

1.构造sigmoid函数

import numpy as np # this means you can access numpy functions by writing np.function() instead of numpy.function()

def sigmoid(x):
    s=none
    s=1.0/(1.0+np.exp(-x)
    return s

2.构造ds

import numpy as np
def sigmoid_derivative(x):
    s=1.0/(1.0+np.exp(-x))
    ds=s*(1-s)
    return ds
x = np.array([1, 2, 3])
print ("sigmoid_derivative(x) = " + str(sigmoid_derivative(x)))
  1. 维数转换,将一幅RBG图片转换为一维数组。

    def image2vector(image):
     v=None
           v=image.reshape((image.shape[0]*image.shape[1]*image.shape[2]),1)
     return v
    
  2. 矩阵规范化处理
    将矩阵x规范化的函数:
    def normalizeRows(x):
    x_norm=None
    x_norm=np.linalg.norm(x,axis=1,keepdims=True)
    x=x/x_norm
    return x

注:这里得到的x_norm是每行各元素的,平方和,再开根号。

4.1 softmax函数
def softmax(x):
### START CODE HERE ### (≈ 3 lines of code)
# Apply exp() element-wise to x. Use np.exp(…).
x_exp = np.exp(x)

# Create a vector x_sum that sums each row of x_exp. Use np.sum(..., axis = 1, keepdims = True).
x_sum = np.sum(x_exp,axis = 1,keepdims = True)

# Compute softmax(x) by dividing x_exp by x_sum. It should automatically use numpy broadcasting.
s = x_exp/x_sum

### END CODE HERE ###
return s

axis=1 表示以竖轴为基准,同行相加。
keepdims主要用于保持矩阵的二维特性。

  1. L1正则化
    def L1(yhat, y):
    loss = sum(abs(yhat-y))
    return loss

    L2正则化
    def L2(yhat, y):
    loss=np.dot(y-yhat,y-yhat)
    return loss

Exploring an advanced state of the art deep learning models and its applications using Popular python libraries like Keras, Tensorflow, and Pytorch Key Features • A strong foundation on neural networks and deep learning with Python libraries. • Explore advanced deep learning techniques and their applications across computer vision and NLP. • Learn how a computer can navigate in complex environments with reinforcement learning. Book Description With the surge of Artificial Intelligence in each and every application catering to both business and consumer needs, Deep Learning becomes the prime need of today and future market demands. This book explores deep learning and builds a strong deep learning mindset in order to put them into use in their smart artificial intelligence projects. This second edition builds strong grounds of deep learning, deep neural networks and how to train them with high-performance algorithms and popular python frameworks. You will uncover different neural networks architectures like convolutional networks, recurrent networks, long short term memory (LSTM) and solve problems across image recognition, natural language processing, and time-series prediction. You will also explore the newly evolved area of reinforcement learning and it will help you to understand the state-of-the-art algorithms which are the main engines behind popular game Go, Atari, and Dota. By the end of the book, you will be well versed with practical deep learning knowledge and its real-world applications What you will learn • Grasp mathematical theory behind neural networks and deep learning process. • Investigate and resolve computer vision challenges using convolutional networks and capsule networks. • Solve Generative tasks using Variational Autoencoders and Generative Adversarial Nets (GANs). • Explore Reinforcement Learning and understand how agents behave in a complex environment. • Implement complex natural language processing tasks using recurrent networks (LSTM, GRU), and attention models. Who This Book Is For This book is for Data Science practitioners, Machine Learning Engineers and Deep learning aspirants who have a basic foundation of Machine Learning concepts and some programming experience with Python. A mathematical background with a conceptual understanding of calculus and statistics is also desired
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值