jgj

- ghjh
2024-04-20T14:13:57.681370Z

AI: Neural Networks

- ishan
2023-10-09T19:08:16.791013Z
import numpy as np

inputs = np.array([[0,0],
[0,1],
[1,0],
[1,1]])

labels = np.array([0,0,0,1])

def step_function(x):
return 1 if x >= 0 else 0

def train_AND( inputs , labels, lr = 0.1 , epochs= 10):
w , b = np.random.rand( inputs.shape[1]) , np.random.rand()

for i in range(epochs):
for x , y in zip(inputs , labels):
pred = step_function(np.dot(x,w) + b)
error = y - pred
w += lr * error * x
b += lr * error
print(f'Iteration:{i} , Weights:{w} , bais:{b}')

return w , b

weights, bias = train_AND(inputs,labels)

ma coder ho no 1

- Akhiseno Ghalan
2023-10-09T17:27:31.202290Z
have fun and chill harder

dsap lab2.2

- ritik
2023-10-09T17:27:30.337206Z
size=11
x=np.ones(size,dtype=int)
n=range(0,11,1)
n1=range(0,21,1)
h=[]
for i in n:
temp=pow(2,n[i])
h.append(temp)
y=np.convolve(x,h,mode='full')

plt.subplot(2,2,1)
plt.stem(n,x)
plt.title("x[n]")
plt.subplot(2,2,2)
plt.title("h[n]")
plt.stem(n,h)
plt.tight_layout()
plt.subplot(2,2,3)
plt.title("y[n]")
plt.stem(n1,y)
plt.tight_layout()

cc =linear

- shree
2023-10-09T17:27:29.463642Z
gfd

dsap lab2.2

- ritik
2023-10-09T17:27:28.607008Z
size=11
x=np.ones(size,dtype=int)
n=range(0,11,1)
n1=range(0,21,1)
h=[]
for i in n:
temp=pow(2,n[i])
h.append(temp)
y=np.convolve(x,h,mode='full')

plt.subplot(2,2,1)
plt.stem(n,x)
plt.title("x[n]")
plt.subplot(2,2,2)
plt.title("h[n]")
plt.stem(n,h)
plt.tight_layout()
plt.subplot(2,2,3)
plt.title("y[n]")
plt.stem(n1,y)
plt.tight_layout()

circular convolve

- shree
2023-10-09T17:27:27.761499Z
x = np.array([2,1,2,1])
h = np.array([1,2,3,4])
DFT_x=np.fft.fft(x)
DFT_h=np.fft.fft(h)
print(DFT_x)
print(DFT_h)
y=DFT_x*DFT_h
print(y)
cc=DFT_h=np.fft.ifft(y)
print(cc)

idft

- asd
2023-10-09T17:27:26.893382Z
DFT = np.array([10,-2+2j,-2,-2-2j])
x=np.fft.ifft(DFT)
print(x)
plt.stem(x)

3 line xa yar

- asdf
2023-10-09T17:27:26.049839Z
x = np.array([0,1,2,3])
DFT_result=np.fft.fft(x)
print(DFT_result)

dsap lab2.2

- ritik
2023-10-09T17:27:25.201507Z
size=11
x=np.ones(size,dtype=int)
n=range(0,11,1)
n1=range(0,21,1)
h=[]
for i in n:
temp=pow(2,n[i])
h.append(temp)
y=np.convolve(x,h,mode='full')

plt.subplot(2,2,1)
plt.stem(n,x)
plt.title("x[n]")
plt.subplot(2,2,2)
plt.title("h[n]")
plt.stem(n,h)
plt.tight_layout()
plt.subplot(2,2,3)
plt.title("y[n]")
plt.stem(n1,y)
plt.tight_layout()

dsap lab2.2

- ritik
2023-10-09T17:27:24.329674Z
size=11
x=np.ones(size,dtype=int)
n=range(0,11,1)
n1=range(0,21,1)
h=[]
for i in n:
temp=pow(2,n[i])
h.append(temp)
y=np.convolve(x,h,mode='full')

plt.subplot(2,2,1)
plt.stem(n,x)
plt.title("x[n]")
plt.subplot(2,2,2)
plt.title("h[n]")
plt.stem(n,h)
plt.tight_layout()
plt.subplot(2,2,3)
plt.title("y[n]")
plt.stem(n1,y)
plt.tight_layout()

dsap lab2.1

- ritik
2023-10-09T17:27:23.489868Z
import matplotlib.pyplot as plt
import numpy as np
x=np.array([1,2,3,4,5])
h=np.array([1,2,3,4,5])
y=np.convolve(x,h,mode='full')
print(y)
n=range(0,9,1)
n1=range(0,5,1)
plt.subplot(2,2,1)
plt.stem(n1,x)
plt.title("x")
plt.subplot(2,2,2)
plt.title("h")
plt.stem(n1,h)
plt.tight_layout()
plt.subplot(2,2,3)
plt.title("y")
plt.stem(n,y)
plt.tight_layout()

dsap lab2.1

- ritik
2023-10-09T17:27:21.969896Z
import matplotlib.pyplot as plt
import numpy as np
x=np.array([1,2,3,4,5])
h=np.array([1,2,3,4,5])
y=np.convolve(x,h,mode='full')
print(y)
n=range(0,9,1)
n1=range(0,5,1)
plt.subplot(2,2,1)
plt.stem(n1,x)
plt.title("x")
plt.subplot(2,2,2)
plt.title("h")
plt.stem(n1,h)
plt.tight_layout()
plt.subplot(2,2,3)
plt.title("y")
plt.stem(n,y)
plt.tight_layout()

adsf

- ty45t
2023-10-09T17:27:21.122698Z
x= np.array([1,2,3,4,5])
h= np.array([1,2,3,4,5])
y=np.convolve(x,h,mode='full')
print(y)
n=range(0,9,1)

n1=range(0,5,1)
plt.subplot(2,2,1)
plt.stem(n,y)
plt.title('convolution')

plt.subplot(2,2,2)
plt.stem(n1,x)
plt.title('x')

plt.subplot(2,2,3)
plt.stem(n1,h)
plt.title('h')

no. 1

- shee
2023-10-09T17:27:20.284321Z
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1,2,3,4,5])
h = np.array([1,2,3,4,5])
y = np.convolve(x,h,mode='full')
print(y)
n=range(0,9,1)
plt.subplot(2,2,1)
plt.stem(n,y)

ai-lab-2- prolog

- anon
2023-10-09T17:27:19.408726Z
Q2. Write the following statement in FOPL and then converting them in prologprogram test the following goal.
* every american who sells weapons to hostile nation is a criminal.
* Every enemy of america is hostile.
* Iraque has some missiles.
* \all the missiles of iraque were sold by George.
* Iraque is a country.
* Missiles are weapons

Q3. Write the following statement in FOPL and then converting them in prologprogram test the following goal
* Horses are mammals.
* an offspring of horse is a horse.
* Bluebeards is a charlie's parent.
Now, check if Charlie is a horse?

ai-lab2

- ion-dada-don
2023-10-09T17:27:18.087583Z
main:-
write('this is main mf!').

in_room(bananas).
in_room(chair).
in_room(monkey).
clever(monkey).
tall(chair).
can_move(monkey,chair,bananas).
can_climb(monkey,chair).

can_reach(X,Y):-
clever(X),
close_enough(X,Y).
close_enough(X,Z):-
can_climb(X,Y),
under(Y,Z),
tall(Y).
under(Y,Z):-
in_room(X),
in_room(Y),
in_room(Z),
can_move(X,Y,Z).

ai-prolog-lab1

- anon
2023-10-09T17:27:08.827284Z
main:-
write('this is main MF').

bigger(elephant, horse).
bigger(whatle, elephant).

% this is single line comment



%2. Find hcf of two numbers

hcf(0,X,X) :- !.
hcf(X,0,X) :- !.

hcf(X, Y, Result):-
X >= Y,
X1 is X - Y,
hcf(X1, Y, Result).

hcf(X, Y, Result):-
X < Y,
Y1 is Y - X,
hcf(X, Y1, Result).

% hcf(2,8, Res)


%3. Following are the facts about size of animals
bigger(elephant, whale).
bigger(whale, horse).
bigger(horse, dog).
bigger(dog,cat).
bigger(cat, mouse).
bigger(mouse, cockroach).
bigger(cockroach, housefly).

bigger(X, Y):-
bigger(X, Z), bigger(Z, X).

/*
is elephant bigger than whale
is elephant bigger than whale
bigger(horse, elephant) % no

*/


%5








mother(sumitra, laxman).
mother(sumitra, satrughan).
husband(dasrath, sumitra).
husband(dasrath, kaikai).
husband(dasrath, kausalya).
son(X,Y).

% logic
son(A,C):-
mother(C,A).
son(A,C):-
husband(C,B).
mother(B,A).
son(A,C):-
husband(B,C).
father(B,D).
father(A,B):-
husband(A,C).
mother(C,B).
% husband(X, Y):
% who is son of kaikai?
% son(kaikai).
% who are parents of ram
% who is father of ram
% who are son of dasrath?

mkmkm

- kj
2023-10-09T17:27:08.334548Z
hcf(0,X,X) :- !.
hcf(X,0,X) :- !.

hcf(X,Y,Result) :-
X>=Y,
X1 is X-Y,
hcf(X1,Y,Result).

hcf(X,Y,Result) :-
X<Y,
Y1 is Y-X,
hcf(X,Y1,Result).

bigger(elephant,whale).
bigger(whale,horse).
bigger(horse,dog).
bigger(dog,cat).
bigger(cat,mouse).
bigger(mouse,cockroach).
bigger(cockroach,housefly).

bigger(X,Y) :- bigger(X,Z) , bigger(Z,Y).


mother(kaushalya,ram).
mother(kaikai,bharat).
mother(sumitra,laxman).
mother(sumitra,satrughan).

husband(dasarath, kaushalya).
husband(dasarath, kaikai).
husband(dasarath, sumitra).

son(A,C):-
mother(C,A).
son(A,C):-
husband(C,B).
mother(B,A).
father(A,B):-
husband(A,C).
mother(C,B).


3dsap

- bikki
2023-10-09T17:27:07.848417Z
n = range(-5, 5, 1)
y = []
x=[]
z=[]
a=[]
for i in range(len(n)):
temp = math.pow(2,i)
temp2 = math.pow(-2,i)
temp3 = math.pow(0.5,i)
temp4 = math.pow(-0.5,i)

y.append(temp)
x.append(temp2)
z.append(temp3)
a.append(temp4)
plt.subplot(2, 2, 1)
plt.stem(n, y)
plt.title("2^n function")
plt.grid(True)
plt.xlabel("n")
plt.ylabel("x[n]")
plt.subplot(2, 2, 2)
plt.stem(n, x)
plt.title("-2^n function")
plt.grid(True)
plt.xlabel("n")
plt.ylabel("x[n]")
plt.subplot(2, 2, 3)
plt.stem(n, z)
plt.title("0.5^n function")
plt.grid(True)
plt.xlabel("n")
plt.ylabel("x[n]")
plt.subplot(2, 2, 4)
plt.stem(n, a)
plt.title("-0.5^n function")
plt.grid(True)
plt.xlabel("n")
plt.ylabel("x[n]")
plt.suptitle("Plot x(n)=a^n")
plt.tight_layout()

unit step fucntion

- bikki
2023-10-09T17:27:07.339179Z
n=range(-5,5,1)
y=[]
for i in range(len(n)):
temp =(1 if n[i]>0 else 0)
y.append (temp)


plt.stem(n,y)
plt.title ('Unit step function')
plt.grid('true')
plt.xlabel('n')
plt.ylabel('x[n]')

3 DSAP

- ritik
2023-10-09T17:27:06.872753Z
n = range(-5, 5, 1)
y = []
x=[]
z=[]
a=[]
for i in range(len(n)):
temp = (2**i)
temp2=(-2**i)
temp3 = (0.5**i)
temp4=(-0.5**i)
y.append(temp)
x.append(temp2)
z.append(temp3)
a.append(temp4)
plt.subplot(2, 2, 1)
plt.stem(n, y)
plt.title("2^n function")
plt.xlabel("n")
plt.ylabel("x[n]")
plt.subplot(2, 2, 2)
plt.stem(n, x)
plt.title("-2^n function")
plt.xlabel("n")
plt.ylabel("x[n]")
plt.subplot(2, 2, 3)
plt.stem(n, z)
plt.title("0.5^n function")
plt.xlabel("n")
plt.ylabel("x[n]")
plt.subplot(2, 2, 4)
plt.stem(n, a)
plt.title("-0.5^n function")
plt.xlabel("n")
plt.ylabel("x[n]")
plt.suptitle("DSAP-Ritik Krishna Shrestha")
plt.tight_layout()

unit step fucntion

- bikki
2023-10-09T17:27:06.387506Z
n=range(-5,5,1)
y=[]
for i in range(len(n)):
temp =(1 if n[i]>0 else 0)
y.append (temp)


plt.stem(n,y)
plt.title ('Unit step function')
plt.grid('true')
plt.xlabel('n')
plt.ylabel('x[n]')

unit step fucntion

- bikki
2023-10-09T17:27:05.902561Z
n=range(-5,5,1)
y=[]
for i in range(len(n)):
temp =(1 if n[i]>0 else 0)
y.append (temp)


plt.stem(n,y)
plt.title ('Unit step function')
plt.grid('true')
plt.xlabel('n')
plt.ylabel('x[n]')

Unit step

- fjhdkjsfb
2023-10-09T17:27:05.440375Z
def unit_step(t):
return np.where(t >= 0, 1,0)

# Generate unit step signal
y = unit_step(t)

# Plotting
plt.plot(t, y)
plt.title("Unit Step Signal")
plt.xlabel("Time")
plt.ylabel("Amplitude")
plt.grid(True)
plt.show()